import com.sun.org.apache.xerces.internal.util.SynchronizedSymbolTable;
import jdk.management.cmm.SystemResourcePressureMXBean;

import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.*;
import java.util.List;
import java.math.*;

public class Newbie {

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        solver s = new solver();
        int t = 1;
        while (t > 0) {
            s.solve();
            t--;
        }
        out.close();
    }

   /* static class descend implements Comparator<pair1> {
        public int compare(pair1 o1, pair1 o2) {
            if (o1.pop != o2.pop)
                return (int) (o1.pop - o2.pop);
            else
                return o1.in - o2.in;
        }
    }*/

    static class InputReader {
        public BufferedReader br;
        public StringTokenizer token;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream), 32768);
            token = null;
        }

        public String next() {
            while (token == null || !token.hasMoreTokens()) {
                try {
                    token = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return token.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    static class card {
        long a;
        int cnt;
        int i;

        public card(long a, int cnt, int i) {
            this.a = a;
            this.cnt = cnt;
            this.i = i;
        }
    }

    static class ascend implements Comparator<pair> {
        public int compare(pair o1, pair o2) {
            return o1.a - o2.a;
        }
    }

    static class extra {

        static boolean v[] = new boolean[100001];
        static List<Integer> l = new ArrayList<>();
        static int t;

        static void shuffle(long a[]) {
            List<Long> l = new ArrayList<>();
            for (int i = 0; i < a.length; i++)
                l.add(a[i]);
            Collections.shuffle(l);
            for (int i = 0; i < a.length; i++)
                a[i] = l.get(i);
        }

        static long gcd(long a, long b) {
            if (b == 0)
                return a;
            else
                return gcd(b, a % b);
        }

        static boolean valid(int i, int j, int r, int c) {
            if (i >= 0 && i < r && j >= 0 && j < c)
                return true;
            else
                return false;
        }

        static void seive() {
            for (int i = 2; i < 100001; i++) {
                if (!v[i]) {
                    t++;
                    l.add(i);
                    for (int j = 2 * i; j < 100001; j += i)
                        v[j] = true;
                }
            }
        }

        static int binary(long a[], long val, int n) {
            int mid = 0, l = 0, r = n - 1, ans = 0;
            while (l <= r) {
                mid = (l + r) >> 1;
                if (a[mid] == val) {
                    r = mid - 1;
                    ans = mid;
                } else if (a[mid] > val)
                    r = mid - 1;
                else {
                    l = mid + 1;
                    ans = l;
                }
            }
            return (ans + 1);
        }

        static long fastexpo(int x, int y) {
            long res = 1;
            while (y > 0) {
                if ((y & 1) == 1) {
                    res *= x;
                }
                y = y >> 1;
                x = x * x;
            }
            return res;
        }

        static long lfastexpo(int x, int y, int p) {
            long res = 1;
            x = x % p;
            while (y > 0) {
                if ((y & 1) == 1) {
                    res = (res * x) % p;
                }
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }
    }

    static class pair {
        int a;
        int b;

        public pair(int a, int i) {
            this.a = a;
            this.b = i;
        }
    }

    static class pair1 {
        pair p;
        int in;

        public pair1(pair a, int n) {
            this.p = a;
            this.in = n;
        }
    }

    static long m = (long) 1e9 + 7;

    static class solver {
        void solve() {
            int n = sc.nextInt();
            int ans=0;
            int a[]=new int[2*n];
            for (int i = 0; i < 2 * n; i++) {
               a[i]=sc.nextInt();
            }
            for(int i=0;i<2*n;i++)
            {
                if(a[i]>0)
                {
                    int j=0;
                    for(j=i+1;a[i]!=a[j];j++)
                    {
                        if(a[j]>0)
                            ans++;
                    }
                    a[j]=0;
                }
            }
            System.out.println(ans);
        }
    }
}


import java.io.*;
import java.util.*;

public class Main {

    private static void solve(InputReader in, OutputWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();

        String[] sa = new String[n];
        for (int i = 0; i < n; i++) {
            sa[i] = in.next();
        }

        Set<Integer> switches = new HashSet<>();
        for (int i = 0; i < m; i++) {
            int cnt = 0, swtch = -1;
            for (int j = 0; j < n; j++) {
                if (sa[j].charAt(i) == '1') {
                    cnt++;
                    swtch = j;
                    if (cnt > 1)
                        break;
                }
            }

            if (cnt == 1) {
                switches.add(swtch);
            }
        }

        out.print(switches.size() == n ? "NO" : "YES");
    }

    private static void shuffleArray(int[] array) {
        int index;
        Random random = new Random();
        for (int i = array.length - 1; i > 0; i--) {
            index = random.nextInt(i + 1);
            if (index != i) {
                array[index] ^= array[i];
                array[i] ^= array[index];
                array[index] ^= array[i];
            }
        }
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);
        solve(in, out);
        in.close();
        out.close();
    }

    private static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        InputReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }

        String nextLine() {
            String line = null;
            try {
                line = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return line;
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String line = nextLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static class OutputWriter {
        BufferedWriter bw;

        OutputWriter(OutputStream os) {
            bw = new BufferedWriter(new OutputStreamWriter(os));
        }

        void print(int i) {
            print(Integer.toString(i));
        }

        void println(int i) {
            println(Integer.toString(i));
        }

        void print(long l) {
            print(Long.toString(l));
        }

        void println(long l) {
            println(Long.toString(l));
        }

        void print(double d) {
            print(Double.toString(d));
        }

        void println(double d) {
            println(Double.toString(d));
        }

        void print(boolean b) {
            print(Boolean.toString(b));
        }

        void println(boolean b) {
            println(Boolean.toString(b));
        }

        void print(char c) {
            try {
                bw.write(c);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void println(char c) {
            println(Character.toString(c));
        }

        void print(String s) {
            try {
                bw.write(s);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void println(String s) {
            print(s);
            print('\n');
        }

        void close() {
            try {
                bw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class CodeForces
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		System.out.println(input.nextInt() / 2 + 1);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class MicroWorld {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());

		int n = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());

		int[] temp = new int[1000001];

		StringTokenizer st1 = new StringTokenizer(br.readLine());

		for (int i = 0; i < n; i++){

			temp[Integer.parseInt(st1.nextToken())]++;
		}

		int b = k + 1;

		for (int i = 1000000; i > 0; i--){

			if (temp[i] > 0){
				if (b <= k){
					n -= temp[i];
				}
				b = 1;
			}else{
				b++;
			}
		}

		System.out.println(n);

	}

}


import java.util.*;
import java.io.*;

public class SonyaExhibition {
	static BufferedReader br;
	static StringTokenizer tokenizer;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		int n = nextInt();
		int[] arr = {0,1};
		for(int i = 0; i < n; i++) {
			System.out.print(arr[i % 2]);
		}
		System.out.println();
	}

	public static String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null)
				throw new IOException();
			tokenizer = new StringTokenizer(line);
		}
		return tokenizer.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
}


import java.io.*;
import java.util.*;

public class ayyyyyy
{
	public static void main(String[] args) { new ayyyyyy(); }
	Scanner in = new Scanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	int t, n;
	int[] a;

	ayyyyyy()
	{
		t = in.nextInt();
		while (t --> 0)
		{
			a = new int[n = in.nextInt()];
			for (int i = 0; i < n; i++)
				a[i] = in.nextInt();
			shuffle(a);
			Arrays.sort(a);
			out.println(Math.min(n-2, a[n-2]-1));
		}

		out.close();
	}

	void shuffle(int[] x)
	{
		for (int i = 0; i < n; i++)
		{
			int swp = (int)(n*Math.random());
			int tmp = x[swp];
			x[swp] = x[i];
			x[i] = tmp;
		}
	}
}


//package contese_476;
import java.util.*;
public class q1
{
	int m=(int)1e9+7;
public class Node
{
	int a;
	int b;
	public void Node(int a,int b)
	{
		this.a=a;
		this.b=b;
	}
}
public int mul(int a ,int b)
{
a=a%m;
b=b%m;
return((a*b)%m);
}
public int pow(int a,int b)
{
	int x=1;
	while(b>0)
	{
		if(b%2!=0)
			x=mul(x,a);
		a=mul(a,a);
		b=b/2;
	}
	return x;
}
public static long gcd(long a,long b)
{
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
public static void main(String[] args)
{
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	HashMap<Integer,Integer> h=new HashMap();
	//HashMap<Integer,Integer> h1=new HashMap();
	int[] a=new int[n];
	int x=sc.nextInt();
	for(int i=0;i<n;i++)
	{
		a[i]=sc.nextInt();
		if(h.get(a[i])==null)
		{
			h.put(a[i], 1);
			//h1.put(a[i],i);
		}
		else
		{
			System.out.print(0);
			System.exit(0);
		}
	}
	for(int i=0;i<n;i++)
	{
		int num=a[i]&x;
		if(num==a[i])
			continue;
		if(h.get(num)==null)
			continue;

		else
		{

			System.out.print(1);
			System.exit(0);
		}
	}
	for(int i=0;i<n;i++)
	{
		int num=a[i]&x;
		if(num==a[i])
			continue;
		if(h.get(num)==null)
			h.put(num, 1);
		else
		{
			System.out.print(2);
			System.exit(0);
		}
	}
	System.out.print(-1);

}

}


import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Practice {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String[] arr1 = new String[n];
            String[] arr2 = new String[n];
            for (int i = 0; i < n; i++) {
                arr1[i] = in.next();
            }
            for (int i = 0; i < n; i++) {
                arr2[i] = in.next();
            }
            int ans = 0;
            boolean arr[]=new boolean[n];
            boolean found=false;
            for (int i = 0; i < arr1.length; i++) {
                for(int j=0;j<arr1.length;j++){
                    found=false;
                    if(arr1[i].equals(arr2[j]) && !arr[j]){
                        found=true;
                        arr[j]=true;
                        break;
                    }
                }
                if(!found){
                    ans++;
                }
            }
            out.println(ans);
        }
    }

    public static boolean checkPrime(int n, int p) {
        for (int i = 2; i <= Math.sqrt(n) && i <= p; i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static void mergeArrays(int[] arr1, int[] arr2, int n1,
            int n2, int[] arr3) {
        int i = 0, j = 0, k = 0;
        while (i < n1 && j < n2) {
            if (arr1[i] < arr2[j]) {
                arr3[k++] = arr1[i++];
            } else {
                arr3[k++] = arr2[j++];
            }
        }
        while (i < n1) {
            arr3[k++] = arr1[i++];
        }
        while (j < n2) {
            arr3[k++] = arr2[j++];
        }
    }

    public long GCD(long a, long b) {
        if (b == 0) {
            return a;
        }
        return GCD(b, a % b);
    }

    public static long nCr(int n, int r) {
        return n * (n - 1) / 2;
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author sumit
 */
public class Main {
      public static void main(String[] args) {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            InputReader in = new InputReader(inputStream);
            OutputWriter out = new OutputWriter(outputStream);
            CChessboard solver = new CChessboard();
            solver.solve(1, in, out);
            out.close();
      }

      static class CChessboard {
            int[] nextPermutation(int[] array) {
                  int i = array.length - 1;
                  while (i > 0 && array[i - 1] >= array[i]) {
                        i--;
                  }

                  if (i <= 0) {
                        return null;
                  }

                  int j = array.length - 1;

                  while (array[j] <= array[i - 1]) {
                        j--;
                  }

                  int temp = array[i - 1];
                  array[i - 1] = array[j];
                  array[j] = temp;

                  j = array.length - 1;

                  while (i < j) {
                        temp = array[i];
                        array[i] = array[j];
                        array[j] = temp;
                        i++;
                        j--;
                  }

                  return array;
            }

            public void solve(int testNumber, InputReader in, OutputWriter out) {
                  int n = in.nextInt();
                  int arr[][][] = new int[4][n][n];
                  int sum[] = new int[4];

                  for (int k = 0; k < 4; k++) {
                        for (int i = 0; i < n; i++) {
                              String str = in.next();
                              for (int j = 0; j < n; j++) {
                                    arr[k][i][j] = (str.charAt(j) - '0');
                              }
                        }
                  }

                  for (int k = 0; k < 4; k++) {
                        for (int i = 0; i < n; i++) {
                              for (int j = 0; j < n; j++) {
                                    if ((i + j) % 2 == arr[k][i][j])
                                          sum[k]++;
                              }
                        }
                  }

                  int perm[] = new int[4];
                  for (int i = 0; i < 4; i++)
                        perm[i] = i;

                  int min = Integer.MAX_VALUE;
                  while (true) {
                        perm = nextPermutation(perm);

                        if (perm == null)
                              break;

                        int sm = 0;
                        for (int j = 0; j < 4; j++) {
                              if (j % 2 == 0) {
                                    sm += (sum[perm[j]]);
                              } else {
                                    sm += (n * n - sum[perm[j]]);
                              }
                        }
                        min = Math.min(min, sm);

                        sm = 0;
                        for (int j = 0; j < 4; j++) {
                              if (j % 2 == 0) {
                                    sm += (n * n - sum[perm[j]]);
                              } else {
                                    sm += (sum[perm[j]]);
                              }
                        }
                        min = Math.min(sm, min);

                  }
                  out.printLine(min);

            }

      }

      static class OutputWriter {
            private final PrintWriter writer;

            public OutputWriter(OutputStream outputStream) {
                  writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
            }

            public OutputWriter(Writer writer) {
                  this.writer = new PrintWriter(writer);
            }

            public void close() {
                  writer.close();
            }

            public void printLine(int i) {
                  writer.println(i);
            }

      }

      static class InputReader {
            private InputStream stream;
            private byte[] buf = new byte[1024];
            private int curChar;
            private int numChars;

            public InputReader(InputStream stream) {
                  this.stream = stream;
            }

            public int read() {
                  if (numChars == -1)
                        throw new InputMismatchException();

                  if (curChar >= numChars) {
                        curChar = 0;
                        try {
                              numChars = stream.read(buf);
                        } catch (IOException e) {
                              throw new InputMismatchException();
                        }
                        if (numChars <= 0)
                              return -1;
                  }

                  return buf[curChar++];
            }

            public int nextInt() {
                  int c = read();

                  while (isSpaceChar(c))
                        c = read();

                  int sgn = 1;

                  if (c == '-') {
                        sgn = -1;
                        c = read();
                  }

                  int res = 0;

                  do {
                        if (c < '0' || c > '9')
                              throw new InputMismatchException();

                        res *= 10;
                        res += c & 15;

                        c = read();
                  } while (!isSpaceChar(c));

                  return res * sgn;
            }

            public String next() {
                  int c = read();

                  while (isSpaceChar(c))
                        c = read();

                  StringBuilder res = new StringBuilder();

                  do {
                        res.appendCodePoint(c);

                        c = read();
                  } while (!isSpaceChar(c));

                  return res.toString();
            }

            public boolean isSpaceChar(int c) {
                  return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
            }

      }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner read = new Scanner(System.in);
        double a = (double)read.nextInt();
        double v = (double)read.nextInt();
        double l = (double)read.nextInt();
        double d = (double)read.nextInt();
        double w = (double)read.nextInt();
        double t=0;
        if(w>=v){
            double d1=v*v/(2*a);
            if(d1>l){
                t+= Math.sqrt(2*l/a);
            }
            else{
                t+= v/a + (l-d1)/v;
            }
        }
        else{
            double temp = (v-w)/a;
            double d1 = v*v/(2*a);
            double d2 = d - v*temp + a*temp*temp/2;
            if(d1>d2){
                double temp2 = Math.sqrt(2*a*d);
                if(temp2<w){
                    w=temp2;
                    temp=(v-w)/a;
                    t+= temp2/a;
                }
                else{
                    double vx=Math.sqrt(v*v/2+a*d2);
                    t+= (vx/a) + ((vx-w)/a);
                }
            }
            else{
                t+= (v/a) + ((d2-d1)/v) + (temp);
            }
            double d3 = d + w*temp + a*temp*temp/2;
            if(d3>l){
                t+= (-w+Math.sqrt(w*w+2*a*(l-d)))/a;
            }
            else{
                t+= (temp) + ((l-d3)/v);
            }
        }
        System.out.printf("%.6f", t);
        read.close();
    }
}


import java.util.*;
import java.io.*;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String s1[]=br.readLine().split(" ");
            int n=Integer.parseInt(s1[0]);
            int m=Integer.parseInt(s1[1]);
            int a[]=new int[n];
            String s2[]=br.readLine().split(" ");
            long S=0;
            for(int i=0;i<n;i++)
            { a[i]=Integer.parseInt(s2[i]);  S+=(long)a[i]; }

            Arrays.sort(a);
            m=a[n-1];
            int last=1;
            int t=1;
            for(int i=1;i<n-1;i++)
            {
                  if(a[i]==last)
                   t++;
                  else
                  {
                        t++;
                        last=last+1;
                  }
            }
            if(last<m)
            { t+=m-last; }
            else
             t++;
            System.out.println(S-t);
      }
}


import java.util.Arrays;
import java.util.Scanner;

public class Solution {

    private static int[] a;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(), m = sc.nextInt();

        a = new int[101];
        for (int i = 0; i < m; i++) {
            int type = sc.nextInt();
            a[type] = a[type] + 1;
        }

        int lo=1, hi=100, max=0;

        while (lo <= hi) {
            int mid = lo + (hi - lo)/2;
            if (check(n, mid)) {
                max = mid;
                lo = mid+1;
            } else {
                hi = mid -1;
            }
        }
        System.out.println(max);
    }

    public static boolean check(int n, int target) {
        int result = 0;
        for (int i=0; i <a.length; i++) {
            result = result + (a[i] / target);
        }
        if (result >= n) {return true;}
        return false;
    }
}


import java.util.*;

public class ErrorCorrectSystem
{

	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String a = scan.next();
		String b = scan.next();

		int[][] mismatch = new int[26][26];
		for(int i = 0; i < 26; i++) Arrays.fill(mismatch[i], -1);
		int[][] pair = new int[2][26];
		for(int i = 0; i < 2; i++) Arrays.fill(pair[i], -1);
		int hd = 0;
		for(int i = 0; i < n; i++) {
			if(a.charAt(i) != b.charAt(i)) {
				hd++;
				mismatch[a.charAt(i)-'a'][b.charAt(i)-'a'] = i;
				pair[0][a.charAt(i)-'a'] = i;
				pair[1][b.charAt(i)-'a'] = i;
			}
		}
		for(int i = 0; i < 26; i++) {
			for(int j = i+1; j < 26; j++) {
				if(mismatch[i][j] > -1 && mismatch[j][i] > -1) {
					System.out.println(hd-2);
					System.out.println((mismatch[i][j]+1)+" "+(mismatch[j][i]+1));
					return;
				}
			}
		}
		for(int i = 0; i < n; i++) {
			if(a.charAt(i) != b.charAt(i)) {
				//try a gets b's letter
				if(pair[0][b.charAt(i)-'a'] > -1) {
					System.out.println(hd-1);
					System.out.println((i+1)+" "+(pair[0][b.charAt(i)-'a']+1));
					return;
				}
			}
		}

		System.out.println(hd);
		System.out.println("-1 -1");
	}

}


import java.io.*;
import java.util.Arrays;
import java.util.Random;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Function;

public class Main {

    static int T;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        T = sc.nextInt();

        PrintWriter pw = new PrintWriter(System.out);
        for (int i = 0; i < T; i++) {
            int n = sc.nextInt();
            int[] a = sc.nextIntArray(n);
            int[] ans = solve(n, a);
            StringJoiner j = new StringJoiner(" ");
            for (int each : ans) {
                j.add(String.valueOf(each));
            }
            pw.println(j.toString());
        }
        pw.flush();
    }

    static int[] solve(int N, int[] A) {
        // a/b が1に近いものを探す
        shuffle(A);
        Arrays.sort(A);
        int cur = A[0];
        int time = 1;
        double r = 0;
        int prev = -1;
        int a = -1;
        int b = -1;
        for (int i = 1; i < N; i++) {
            if( cur == A[i] ) {
                time++;

                if( time == 2 ) {
                    if( prev != -1 ) {
                        double r1 = (double)prev/cur;
                        if( r1 > r ) {
                            r = r1;
                            a = prev;
                            b = cur;
                        }
                    }
                    prev = cur;
                }

                if( time == 4 ) {
                    return new int[]{cur, cur, cur, cur};
                }

            } else {
                time = 1;
                cur = A[i];
            }
        }

        return new int[]{a, a, b, b};
    }

    static void shuffle(int[] a) {
        Random r = ThreadLocalRandom.current();
        for (int i = a.length-1; i >= 0; i--) {
            int j = r.nextInt(i+1);
            int t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        int[] nextIntArray(int n, int delta) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt() + delta;
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    static <A> void writeLines(A[] as, Function<A, String> f) {
        PrintWriter pw = new PrintWriter(System.out);
        for (A a : as) {
            pw.println(f.apply(a));
        }
        pw.flush();
    }

    static void writeLines(int[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int a : as) pw.println(a);
        pw.flush();
    }

    static void writeLines(long[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (long a : as) pw.println(a);
        pw.flush();
    }

    static int max(int... as) {
        int max = Integer.MIN_VALUE;
        for (int a : as) max = Math.max(a, max);
        return max;
    }

    static int min(int... as) {
        int min = Integer.MAX_VALUE;
        for (int a : as) min = Math.min(a, min);
        return min;
    }

    static void debug(Object... args) {
        StringJoiner j = new StringJoiner(" ");
        for (Object arg : args) {
            if (arg instanceof int[]) j.add(Arrays.toString((int[]) arg));
            else if (arg instanceof long[]) j.add(Arrays.toString((long[]) arg));
            else if (arg instanceof double[]) j.add(Arrays.toString((double[]) arg));
            else if (arg instanceof Object[]) j.add(Arrays.toString((Object[]) arg));
            else j.add(arg.toString());
        }
        System.err.println(j.toString());
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class ElevatorOrStairs {

	private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	private static final OutputStreamWriter writer = new OutputStreamWriter(System.out);

	public static void main(String...strings) throws Exception {
		String[] specs = reader.readLine().split(" ");

		int x = Integer.parseInt(specs[0]);
		int y = Integer.parseInt(specs[1]);
		int z = Integer.parseInt(specs[2]);
		int t1 = Integer.parseInt(specs[3]);
		int t2 = Integer.parseInt(specs[4]);
		int t3 = Integer.parseInt(specs[5]);

		reader.close();
		String ans = solve(x, y, z, t1, t2, t3);
		writer.append(ans);
		writer.flush();
		writer.close();
	}

	private static String solve(int x, int y, int z, int t1, int t2, int t3) {
		int time_using_stairs = Math.abs(x - y) * t1;
		int elevator_time_between_floor = Math.abs(x - z) * t2;
		int elevator_from_z_to_x = elevator_time_between_floor + 2*t3;

 		int time_using_elevator = elevator_from_z_to_x + (Math.abs(x - y) * t2) + t3;

 		if(time_using_elevator <= time_using_stairs) {
 			return "YES";
 		}
 		return "NO";
	}
}


							import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
											public class Solution1 implements Runnable
											{
												static final long MAX = 1000000007L;
												static class InputReader
												{
													private InputStream stream;
													private byte[] buf = new byte[1024];
													private int curChar;
													private int numChars;
													private SpaceCharFilter filter;
													private BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

													public InputReader(InputStream stream)
													{
														this.stream = stream;
													}

													public int read()
													{
														if (numChars==-1)
															throw new InputMismatchException();

														if (curChar >= numChars)
														{
															curChar = 0;
															try
															{
																numChars = stream.read(buf);
															}
															catch (IOException e)
															{
																throw new InputMismatchException();
															}

															if(numChars <= 0)
																return -1;
														}
														return buf[curChar++];
													}

													public String nextLine()
													{
														String str = "";
											            try
											            {
											                str = br.readLine();
											            }
											            catch (IOException e)
											            {
											                e.printStackTrace();
											            }
											            return str;
													}
													public int nextInt()
													{
														int c = read();

														while(isSpaceChar(c))
															c = read();

														int sgn = 1;

														if (c == '-')
														{
															sgn = -1;
															c = read();
														}

														int res = 0;
														do
														{
															if(c<'0'||c>'9')
																throw new InputMismatchException();
															res *= 10;
															res += c - '0';
															c = read();
														}
														while (!isSpaceChar(c));

														return res * sgn;
													}

													public long nextLong()
													{
														int c = read();
														while (isSpaceChar(c))
															c = read();
														int sgn = 1;
														if (c == '-')
														{
															sgn = -1;
															c = read();
														}
														long res = 0;

														do
														{
															if (c < '0' || c > '9')
																throw new InputMismatchException();
															res *= 10;
															res += c - '0';
															c = read();
														}
														while (!isSpaceChar(c));
															return res * sgn;
													}

													public double nextDouble()
													{
														int c = read();
														while (isSpaceChar(c))
															c = read();
														int sgn = 1;
														if (c == '-')
														{
															sgn = -1;
															c = read();
														}
														double res = 0;
														while (!isSpaceChar(c) && c != '.')
														{
															if (c == 'e' || c == 'E')
																return res * Math.pow(10, nextInt());
															if (c < '0' || c > '9')
																throw new InputMismatchException();
															res *= 10;
															res += c - '0';
															c = read();
														}
														if (c == '.')
														{
															c = read();
															double m = 1;
															while (!isSpaceChar(c))
															{
																if (c == 'e' || c == 'E')
																	return res * Math.pow(10, nextInt());
																if (c < '0' || c > '9')
																	throw new InputMismatchException();
																m /= 10;
																res += (c - '0') * m;
																c = read();
															}
														}
														return res * sgn;
													}

													public String readString()
													{
														int c = read();
														while (isSpaceChar(c))
															c = read();
														StringBuilder res = new StringBuilder();
														do
														{
															res.appendCodePoint(c);
															c = read();
														}
														while (!isSpaceChar(c));

														return res.toString();
													}

													public boolean isSpaceChar(int c)
													{
														if (filter != null)
															return filter.isSpaceChar(c);
														return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
													}

													public String next()
													{
														return readString();
													}

													public interface SpaceCharFilter
													{
														public boolean isSpaceChar(int ch);
													}
												}

												public static void main(String args[]) throws Exception
												{
													new Thread(null, new Solution1(),"Solution1",1<<26).start();
												}
												long gcd(long a, long b)
											    {
											        if (a == 0)
											            return b;

											        return gcd(b%a, a);
											    }
											    // method to return LCM of two numbers
												 long lcm(long a, long b)
												    {
												        return (a*b)/gcd(a, b);
												    }
												 int root(int a){
													 while(arr[a] != a){
														 arr[a] = arr[arr[a]];
														 a = arr[a];
													 }
													 return a;
												 }
												 void union(int a,int b){
													 int xroot = root(a);
													 int yroot = root(b);
													 if(arr[xroot] < arr[yroot]){
														 arr[xroot] = yroot;
													 }else{
														 arr[yroot] = xroot;
													 }
												 }
												 boolean find(int a,int b){
													 int roota = root(a);
													 int rootb = root(b);
													 if(roota == rootb){
														 return true;
													 }else{
														 return false;
													 }
												 }
												 int[] arr;
												 final int level = 20;

												public void run()
												{
													InputReader sc= new InputReader(System.in);
													PrintWriter w= new PrintWriter(System.out);
													int n = sc.nextInt();
													char[] ch = new char[n];
													char[] ch2 = new char[n];
													ch = sc.next().toCharArray();
													ch2 = sc.next().toCharArray();
													HashSet<Integer> hset[] = new HashSet[26];
													for(int i = 0;i < 26;i++){
														hset[i]  =new HashSet();
													}
													int count = 0;
													for(int i = 0;i < ch.length;i++){
														if(ch[i] != ch2[i]){
															hset[ch[i]-97].add(ch2[i]-97);
															count++;
														}
													}
													boolean flag = false;
													int swap1 = -1;
													int swap2 = -1;
													int rem = -1;
													for(int i = 0;i < ch.length;i++){
														if(ch[i] != ch2[i]){
															if(hset[ch2[i]-97].size() != 0){
																swap1 = i;
																flag = true;
																if(hset[ch2[i]-97].contains(ch[i]-97)){
																	rem = i;
																	count-=2;
																	flag = false;
																	break;
																}
															}
														}
													}
													if(flag){
														count--;
														w.println(count);
														for(int i = 0;i < n;i++){
															if(i != swap1 && ch[i] == ch2[swap1] && ch[i] != ch2[i]){
																w.println((swap1+1) + " " + (i+1));
																w.close();
																System.exit(0);
															}
														}
													}else{
														if(rem == -1){
															w.println(count);
															w.println("-1 -1");
														}else{
															w.println(count);
															for(int i = 0;i < n;i++){
																if(i != rem && ch[i] == ch2[rem] && ch[rem] == ch2[i] && ch[i] != ch2[i]){
																	w.println((rem+1) + " " + (i+1));
																	w.close();
																	System.exit(0);
																}
															}
														}
													}
													w.close();
												}
												boolean fun(long[] prefix,long mid,long temp,long[] arr){
													if(temp >= prefix[(int)mid]){
														return true;
													}
													return false;
												}
												static class Pair implements Comparable<Pair>{
													int x;
													int y;

													Pair(){}
													Pair(int x,int y){
														this.x = x;
														this.y = y;

													}
													public int compareTo(Pair p){

														return Long.compare(this.x,p.x);
													}
												}
								}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class SFly {

	public static void main(String[] args) throws IOException {

		BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
		int planet = Integer.parseInt(lector.readLine());
		int ini = Integer.parseInt(lector.readLine());
		double peso = ini;
		int[] desp = new int[planet];
		int[] ater = new int[planet];
		String[] temp = lector.readLine().split(" ");
		for(int i=0; i<planet; i++) {
			desp[i] = Integer.parseInt(temp[i]);
			if(desp[i] == 1) {
				System.out.println(-1);
				lector.close();
				return;
			}
		}
		temp = lector.readLine().split(" ");
		for(int i=0; i<planet; i++) {
			ater[i] = Integer.parseInt(temp[i]);
			if(ater[i] == 1) {
				System.out.println(-1);
				lector.close();
				return;
			}
		}
		temp = null;
		int i=planet-1;
		peso = (peso*ater[0])/(ater[0]-1);
		while(i>0) {
			peso = (peso*desp[i])/(desp[i]-1);
			peso = (peso*ater[i])/(ater[i]-1);
			i--;
		}
		peso = (peso*desp[0])/(desp[0]-1);
		peso = peso - ini;
		System.out.println(peso);
		lector.close();
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
    static BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer tok;
    static boolean hasNext()
    {
        while(tok==null||!tok.hasMoreTokens())
            try{
                tok=new StringTokenizer(in.readLine());
            }
            catch(Exception e){
                return false;
            }
        return true;
    }
    static String next()
    {
        hasNext();
        return tok.nextToken();
    }
    static long nextLong()
    {
        return Long.parseLong(next());
    }
    static int nextInt()
    {
        return Integer.parseInt(next());
    }
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) {
        Map<Integer,Integer> map = new HashMap();
        map.put(0,1);
        int n = nextInt();
        int m = nextInt();
        int index = -1;
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            a[i]=nextInt();
            if(a[i]==m)
                index=i;
        }
        int sum = 0;
        for(int i=0;i<index;i++){
            if (a[i]<m)
                sum--;
            else
                sum++;
            if (map.containsKey(sum)){
                map.put(sum,map.get(sum)+1);
            }else {
                map.put(sum,1);
            }
        }
        long ans = 0;
        for(int i=index;i<n;i++){
            if (a[i]<m)
                sum--;
            else if(a[i]>m)
                sum++;
            if (map.containsKey(sum))
                ans+=map.get(sum);
            if (map.containsKey(sum-1))
                ans+=map.get(sum-1);
        }
        out.print(ans);
        out.flush();
    }
}

1005_E1. Median on Segments (Permutations Edition)


import java.util.HashSet;
import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for(int i = 0; i<n; i++){
            int a = sc.nextInt();
            if(a!=0){
                set.add(a);
            }
        }
        System.out.println(set.size());
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Solution {
    private static int[] dx = {
            -1, -1, -1,
            0, 0,
            1, 1, 1};
    private static int[] dy = {
            -1, 0, 1,
            -1, 1,
            -1, 0, 1};

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

        int r = in.nextInt();
        int c = in.nextInt();
        boolean[][] m = new boolean[r + 1][c + 1];
        boolean[][] inp = new boolean[r + 1][c + 1];
        for (int i = 0; i < r; i++) {
            String s = in.next();
            //System.out.println(m[i]);
            for (int j = 0; j < s.length(); j++) {
                if (s.charAt(j) == '#') {
                    m[i][j] = true;
                    inp[i][j] = true;
                }
            }
        }

        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                if (canPress(i, j, r, c, inp)) {

                    // make press
                    for (int k = 0; k < 8; k++) {
                        int xi = i + dx[k];
                        int yi = j + dy[k];
                        m[xi][yi] = false;
                    }

                }
            }
        }
        boolean isLeftAny = false;
        for (int i = 0; i < r && !isLeftAny; i++) {
            for (int j = 0; j < c && !isLeftAny; j++) {
                if (m[i][j]) {
                    isLeftAny = true;
                    break;
                }
            }
        }
        if(isLeftAny){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }

    private static boolean canPress(int x, int y, int r, int c, boolean[][] inp) {
        for (int i = 0; i < 8; i++) {
            int xi = x + dx[i];
            int yi = y + dy[i];
            if (xi < 0 || yi < 0) {
                return false;
            }
            if (xi >= r || yi >= c) {
                return false;
            }
            if(!inp[xi][yi]){
                return false;
            }
        }
        return true;
    }
}


import java.util.*;
public class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        int m=scan.nextInt();
        int[] game=new int[n];
        int[] bill=new int[m];
        for (int i = 0; i <n ; i++) {
            game[i]=scan.nextInt();
        }
        for (int i = 0; i <m ; i++) {
            bill[i]=scan.nextInt();
        }
        int i=0;
        int j=0;
        int ans=0;
        while (i<m){
            boolean f=true;
            for (int k = j; k <n ; k++) {
                if (bill[i]>=game[k]){
                    ans++;
                    i++;
                    j=k+1;
                    f=false;
                    break;
                }
            }
            if (f){
                break;
            }
        }
        System.out.println(ans);
    }
}


import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Practice {

		public static void main(String []args)
		{
			Scanner sc=new Scanner(System.in);
			int n=sc.nextInt();
			sc.nextLine();
			String s=sc.nextLine();
			//System.out.println(s);
			char c[]=s.toCharArray();
			ArrayList a =new ArrayList();

			for(int i=0;i<c.length;i++)
			{
				//System.out.println(c[i]);
				a.add(c[i]);
			}

			int x=Collections.frequency(a,'0' );
			int y=Collections.frequency(a,'1');

			//System.out.println(x+ "  "+y );
			if(y==0 || y==1)
			{
				System.out.println(s);
			}
			else
			{
				if(y>=2)
				{
					String s1="1";
					for(int i=0;i<x;i++)
					{
						s1=s1+"0";
					}
					System.out.println(s1);

				}
			}

	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        FastReader in;
        PrintWriter out;
        int n;

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            this.in = in;
            this.out = out;
            n = in.nextInt();
            if (n % 4 != 0) {
                out.println("! -1");
                return;
            }
            int low = 0;
            int high = n >> 1;
            int fSign = Integer.signum(BValue(low));
            if (fSign == 0) {
                out.println("! " + (low + 1));
                return;
            }
            while (high - low > 1) {
                int mid = (high + low) >> 1;
                int mSign = Integer.signum(BValue(mid));
                if (mSign == 0) {
                    out.println("! " + (mid + 1));
                    return;
                }
                if (mSign == -fSign) {
                    high = mid;
                } else {
                    low = mid;
                }
            }
            out.println("! -1");
        }

        public int BValue(int index) {
            out.println("? " + (index + 1));
            out.flush();
            int f = in.nextInt();
            out.println("? " + (index + 1 + (n >> 1)));
            out.flush();
            int s = in.nextInt();
            return f - s;
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}


import java.util.*;
import java.io.*;
public class C{
    static PrintWriter out;
    static InputReader in;
    public static void main(String args[]){
        out = new PrintWriter(System.out);
        in = new InputReader();
        new C();
        out.flush(); out.close();
    }
    C(){
       int a = solve();
       out.print(a == 0 ? "tokitsukaze" : a == 1 ? "quailty" : "once again");
    }
    int n, k;
    char ch[]; int a[], c0 = 0, c1 = 0;
    TreeSet<Integer> ts[] = new TreeSet[2];
    boolean check(){
        int min = 0, max = n;
        if(!ts[0].isEmpty()){
            min = ts[0].first(); max = ts[0].last();
            if(max - min + 1 > k)return true;
        }
        if(!ts[1].isEmpty()){
            min = ts[1].first(); max = ts[1].last();
            if(max - min + 1 > k)return true;
        }
        return false;
    }
    int solve(){
        n  = in.nextInt(); k = in.nextInt();
        ch = in.next().trim().toCharArray(); a = new int[n];
        for(int i = 0; i < n; i++)c1 += a[i] = ch[i] - '0';
        c0 = n - c1;
        for(int i = 0; i < k; i++){
            if(a[i] == 0)c0--; else c1--;
        }
        if(c0 == 0 || c1 == 0)return 0;
        for(int i = k; i < n; i++){
            if(a[i] == 0)c0--; else c1--;
            if(a[i - k] == 0)c0++; else c1++;
            if(c0 == 0 || c1 == 0)return 0;
        }

        for(int i = 0; i < 2; i++)ts[i] = new TreeSet<>();
        for(int i = 0; i < n; i++){
            ts[a[i]].add(i);
        }
        for(int i = 0; i < k; i++){
            ts[a[i]].remove(i);
        }
        if(check())return 2;
        for(int i = k; i < n; i++){
            ts[a[i]].remove(i); ts[a[i - k]].add(i - k);
            if(check())return 2;
        }
        return 1;
    }
    public static class InputReader{
        BufferedReader br;
        StringTokenizer st;
        InputReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
        public String next(){
            while(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException e){}
            }
            return st.nextToken();
        }
    }
}


import java.util.*;
import java.io.*;
import java.util.Map.Entry;

public class Codeforces {

    static int n;
    static double max;
    static int[] pre;

    public static void findIntensity(int l){
        for(int i = 0, j = i + l; j < n + 1; i++, j++){
            double res = (pre[j] - pre[i]) / (double) l;
            max = Math.max(max, res);
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        int[] heat = new int[n];
        st = new StringTokenizer(br.readLine());
        for(int i = 0; i < n; i++){
            heat[i] = Integer.parseInt(st.nextToken());
        }
        max = 0;
        pre = new int[n + 1];
        pre[0] = 0;
        for(int i = 0; i < n; i++){
            pre[i + 1] = pre[i] + heat[i];
        }
        for(int i = k; i <= n; i++){
            findIntensity(i);
        }
        System.out.println(max);
    }
}


import java.util.*;
import java.io.*;
public class code{
    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int ok,ok2;
        int va,vb;
        va = 0;
        vb = 0;
        out.println("? "+va+" "+vb);
        out.flush();
        ok = sc.nextInt();
        for(int i=29;i>=0;i--){
            if(ok==0){
                va += (1<<i);
                out.println("? "+va+" "+vb);
                out.flush();
                ok2 = sc.nextInt();
                if(ok2==1){
                    va -= (1<<i);
                }else{
                    vb += (1<<i);
                }
            }else{
                va += (1<<i);
                vb += (1<<i);
                out.println("? "+va+" "+vb);
                out.flush();
                ok2 = sc.nextInt();
                if(ok==ok2){
                    vb -= (1<<i);
                    out.println("? "+va+" "+vb);
                    out.flush();
                    ok2 = sc.nextInt();
                    if(ok2==1){
                        va -= (1<<i);
                    }else{
                        vb += (1<<i);
                    }
                }else{
                    if(ok==1){
                        vb -= (1<<i);
                        out.println("? "+va+" "+vb);
                        out.flush();
                        ok = sc.nextInt();
                    }
                    else {
                        va -= (1<<i);
                        out.println("? "+va+" "+vb);
                        out.flush();
                        ok = sc.nextInt();
                    }
                }
            }
        }
        out.println("! "+va+" "+vb);
        out.flush();
    }
}

1088_D. Ehab and another another xor problem


import java.io.*;
import java.util.*;

public class Main {

    private static void solve(InputReader in, OutputWriter out) {
        int n = in.nextInt();

        if (n < 6) {
            out.println(-1);
        } else {
            int m = (n - 2);
            for (int i = 2; i <= m; i++) {
                out.println("1 " + i);
            }
            out.println(m + " " + (m + 1));
            out.println(m + " " + (m + 2));
        }

        for (int i = 2; i <= n; i++) {
            out.println("1 " + i);
        }
    }

    private static void shuffleArray(int[] array) {
        int index;
        Random random = new Random();
        for (int i = array.length - 1; i > 0; i--) {
            index = random.nextInt(i + 1);
            if (index != i) {
                array[index] ^= array[i];
                array[i] ^= array[index];
                array[index] ^= array[i];
            }
        }
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);
        solve(in, out);
        in.close();
        out.close();
    }

    private static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        InputReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }

        String nextLine() {
            String line = null;
            try {
                line = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return line;
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String line = nextLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        byte nextByte() {
            return Byte.parseByte(next());
        }

        short nextShort() {
            return Short.parseShort(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static class OutputWriter {
        BufferedWriter bw;

        OutputWriter(OutputStream os) {
            bw = new BufferedWriter(new OutputStreamWriter(os));
        }

        void print(int i) {
            print(Integer.toString(i));
        }

        void println(int i) {
            println(Integer.toString(i));
        }

        void print(long l) {
            print(Long.toString(l));
        }

        void println(long l) {
            println(Long.toString(l));
        }

        void print(double d) {
            print(Double.toString(d));
        }

        void println(double d) {
            println(Double.toString(d));
        }

        void print(boolean b) {
            print(Boolean.toString(b));
        }

        void println(boolean b) {
            println(Boolean.toString(b));
        }

        void print(char c) {
            try {
                bw.write(c);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void println(char c) {
            println(Character.toString(c));
        }

        void print(String s) {
            try {
                bw.write(s);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void println(String s) {
            print(s);
            print('\n');
        }

        void close() {
            try {
                bw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

959_C. Mahmoud and Ehab and the wrong algorithm


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.function.Function;

public class P1196D2 {

    static boolean multipleIndependent = true;

    void run() {
        int n = in.nextInt();
        int k = in.nextInt();
        char[] s = in.next().toCharArray();
        int[] dp = new int[3];
        char[] c = {'R', 'G', 'B'};
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < k; i++) {
            dp[0] += s[i] == c[(i + 0) % 3] ? 0 : 1;
            dp[1] += s[i] == c[(i + 1) % 3] ? 0 : 1;
            dp[2] += s[i] == c[(i + 2) % 3] ? 0 : 1;
        }
        min = Math.min(Math.min(Math.min(dp[0], dp[1]), dp[2]), min);
//        System.out.println(Arrays.toString(dp));
        for (int i = k; i < n; i++) {
            dp[0] += (s[i] == c[(i + 0) % 3] ? 0 : 1) - (s[i - k] == c[(i - k + 0) % 3] ? 0 : 1);
            dp[1] += (s[i] == c[(i + 1) % 3] ? 0 : 1) - (s[i - k] == c[(i - k + 1) % 3] ? 0 : 1);
            dp[2] += (s[i] == c[(i + 2) % 3] ? 0 : 1) - (s[i - k] == c[(i - k + 2) % 3] ? 0 : 1);
            min = Math.min(Math.min(Math.min(dp[0], dp[1]), dp[2]), min);
//            System.out.println(Arrays.toString(dp));
        }
        System.out.println(min);
    }

    /* -----: Template :----- */
    static InputReader in = new InputReader(System.in);

    public static void main(String[] args) {
        P1196D2 p = new P1196D2();
        int q = multipleIndependent ? in.nextInt() : 1;
        while (q-- > 0) {
            p.run();
        }
    }

    int numLength(long n) {
        int l = 0;
        while (n > 0) {
            n /= 10;
            l++;
        }
        return l;
    }

    <R> long binarySearch(long lowerBound, long upperBound,
            R value, Function<Long, R> generatorFunction, Comparator<R> comparator) {
        if (lowerBound <= upperBound) {
            long mid = (lowerBound + upperBound) / 2;
            int compare = comparator.compare(generatorFunction.apply(mid), value);
            if (compare == 0) {
                return mid;
            } else if (compare < 0) {
                return binarySearch(mid + 1, upperBound, value, generatorFunction, comparator);
            } else {
                return binarySearch(lowerBound, mid - 1, value, generatorFunction, comparator);
            }
        } else {
            return -1;
        }
    }

    <T> Integer[] sortSimultaneously(T[] key, Comparator<T> comparator,
            Object[]... moreArrays) {
        int n = key.length;
        for (Object[] array : moreArrays) {
            if (array.length != n) {
                throw new RuntimeException("Arrays must have equals lengths");
            }
        }
        Integer[] indices = new Integer[n];
        for (int i = 0; i < n; i++) {
            indices[i] = i;
        }
        Comparator<Integer> delegatingComparator = (a, b) -> {
            return comparator.compare(key[a], key[b]);
        };
        Arrays.sort(indices, delegatingComparator);
        reorder(indices, key);
        for (Object[] array : moreArrays) {
            reorder(indices, array);
        }
        return indices;
    }

    void reorder(Integer[] indices, Object[] arr) {
        if (indices.length != arr.length) {
            throw new RuntimeException("Arrays must have equals lengths");
        }
        int n = arr.length;
        Object[] copy = new Object[n];
        for (int i = 0; i < n; i++) {
            copy[i] = arr[indices[i]];
        }
        System.arraycopy(copy, 0, arr, 0, n);
    }

    int prodMod(int a, int b, int mod) {
        return (int) (((long) a) * b % mod);
    }

    long prodMod(long a, long b, long mod) {
        long res = 0;
        a %= mod;
        b %= mod;
        while (b > 0) {
            if ((b & 1) > 0) {
                res = (res + a) % mod;
            }
            a = (a << 1) % mod;
            b >>= 1;
        }
        return res;
    }

    long sumMod(int[] b, long mod) {
        long res = 0;
        for (int i = 0; i < b.length; i++) {
            res = (res + b[i] % mod) % mod;
        }
        return res;
    }

    long sumMod(long[] a, long mod) {
        long res = 0;
        for (int i = 0; i < a.length; i++) {
            res = (res + a[i] % mod) % mod;
        }
        return res;
    }

    long sumProdMod(int[] a, long b, long mod) {
        long res = sumMod(a, mod);
        return prodMod(res, b, mod);
    }

    long sumProdMod(long[] a, long b, long mod) {
        long res = sumMod(a, mod);
        return prodMod(res, b, mod);
    }

    long sumProdMod(int[] a, int[] b, long mod) {
        if (a.length != b.length) {
            throw new RuntimeException("Arrays must have equals lengths");
        }
        long res = 0;
        for (int i = 0; i < a.length; i++) {
            res = (res + prodMod(a[i], b[i], mod)) % mod;
        }
        return res;
    }

    long sumProdMod(long[] a, long[] b, long mod) {
        if (a.length != b.length) {
            throw new RuntimeException("Arrays must have equals lengths");
        }
        long res = 0;
        for (int i = 0; i < a.length; i++) {
            res = (res + prodMod(a[i], b[i], mod)) % mod;
        }
        return res;
    }

    int[] toPrimitive(Integer[] arr) {
        int[] res = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }

    int[][] toPrimitive(Integer[][] arr) {
        int[][] res = new int[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toPrimitive(arr[i]);
        }
        return res;
    }

    long[] toPrimitive(Long[] arr) {
        long[] res = new long[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }

    long[][] toPrimitive(Long[][] arr) {
        long[][] res = new long[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toPrimitive(arr[i]);
        }
        return res;
    }

    Integer[] toWrapper(int[] arr) {
        Integer[] res = new Integer[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }

    Integer[][] toWrapper(int[][] arr) {
        Integer[][] res = new Integer[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toWrapper(arr[i]);
        }
        return res;
    }

    Long[] toWrapper(long[] arr) {
        Long[] res = new Long[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }

    Long[][] toWrapper(long[][] arr) {
        Long[][] res = new Long[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            res[i] = toWrapper(arr[i]);
        }
        return res;
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public <T> T[] nextIntArray(int n, Function<Integer, T> function, Class<T> c) {
            T[] arr = (T[]) Array.newInstance(c, n);
            for (int i = 0; i < n; i++) {
                arr[i] = function.apply(nextInt());
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        public <T> T[] nextLongArray(int n, Function<Long, T> function, Class<T> c) {
            T[] arr = (T[]) Array.newInstance(c, n);
            for (int i = 0; i < n; i++) {
                arr[i] = function.apply(nextLong());
            }
            return arr;
        }

        public int[][] nextIntMap(int n, int m) {
            int[][] map = new int[n][m];
            for (int i = 0; i < n; i++) {
                map[i] = nextIntArray(m);
            }
            return map;
        }

        public long[][] nextLongMap(int n, int m) {
            long[][] map = new long[n][m];
            for (int i = 0; i < n; i++) {
                map[i] = nextLongArray(m);
            }
            return map;
        }

        public char[][] nextCharMap(int n) {
            char[][] map = new char[n][];
            for (int i = 0; i < n; i++) {
                map[i] = next().toCharArray();
            }
            return map;
        }

        public void readColumns(Object[]... columns) {
            int n = columns[0].length;
            for (Object[] column : columns) {
                if (column.length != n) {
                    throw new RuntimeException("Arrays must have equals lengths");
                }
            }
            for (int i = 0; i < n; i++) {
                for (Object[] column : columns) {
                    column[i] = read(column[i].getClass());
                }
            }
        }

        public <T> T read(Class<T> c) {
            throw new UnsupportedOperationException("To be implemented");
        }

    }

}


import java.io.*;
import java.util.*;
import java.lang.*;
import static java.lang.Math.*;

// _ h _ r _ t r _
// _ t _ t _ s t _

public class TaskA implements Runnable {
    long m = (int)1e9+7;
    PrintWriter w;
    InputReader c;
    final int MAXN = (int)1e6 + 100;
    public void run() {
        c = new InputReader(System.in);
        w = new PrintWriter(System.out);

        int n = c.nextInt(), hamming_distance = 0;
        char[] s = c.next().toCharArray(), t = c.next().toCharArray();
        HashMap<Character, HashSet<Character>> replace = new HashMap<>();
        HashMap<Character, Integer> map = new HashMap<>();

        for(int i=0;i<n;++i) if(s[i] != t[i]) {
            HashSet<Character> temp;
            if(replace.containsKey(s[i])){
                temp = replace.get(s[i]);
                temp.add(t[i]);
            } else {
                temp = new HashSet<>();
                temp.add(t[i]);
            }
            map.put(s[i],i);
            replace.put(s[i], temp);
            hamming_distance++;
        }

        int l = -1, r = -1;
        boolean global_check = false;
        for(int i=0;i<n;i++) if(s[i] != t[i]) {
            if(replace.containsKey(t[i])) {
                HashSet<Character> indices = replace.get(t[i]);
                int ind = map.get(t[i]);
                l = i + 1;
                r = ind + 1;
                if (indices.contains(s[i])) {
                    hamming_distance -= 2;
                    global_check = true;
                    break;
                }
            }
            if(global_check) break;
        }

        if(!global_check && l!=-1) hamming_distance--;
        else if(global_check){
            for(int i=0;i<n;i++) {
                if(t[i] == s[l-1] && s[i] == t[l-1]){
                    r = i + 1;
                    break;
                }
            }
        }
        w.println(hamming_distance);
        w.println(l+" "+r);

        w.close();
    }
    static long gcd(long a, long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
    public static void sortbyColumn(int arr[][], int col){
        Arrays.sort(arr, new Comparator<int[]>()
        {
            public int compare(int[] o1, int[] o2){
                return(Integer.valueOf(o1[col]).compareTo(o2[col]));
            }
        });

    }
    public static class DJSet {
        public int[] upper;

        public DJSet(int n) {
            upper = new int[n];
            Arrays.fill(upper, -1);
        }

        public int root(int x) {
            return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
        }

        public boolean equiv(int x, int y) {
            return root(x) == root(y);
        }

        public boolean union(int x, int y) {
            x = root(x);
            y = root(y);
            if (x != y) {
                if (upper[y] < upper[x]) {
                    int d = x;
                    x = y;
                    y = d;
                }
                upper[x] += upper[y];
                upper[y] = x;
            }
            return x == y;
        }
    }
    public static int[] radixSort(int[] f)    {
        int[] to = new int[f.length];
        {
            int[] b = new int[65537];
            for(int i = 0;i < f.length;i++)b[1+(f[i]&0xffff)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < f.length;i++)to[b[f[i]&0xffff]++] = f[i];
            int[] d = f; f = to;to = d;
        }
        {
            int[] b = new int[65537];
            for(int i = 0;i < f.length;i++)b[1+(f[i]>>>16)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < f.length;i++)to[b[f[i]>>>16]++] = f[i];
            int[] d = f; f = to;to = d;
        }
        return f;
    }
    public void printArray(int[] a){
        for(int i=0;i<a.length;i++)
            w.print(a[i]+" ");
        w.println();
    }
    public int[] scanArrayI(int n){
        int a[] = new int[n];
        for(int i=0;i<n;i++)
            a[i] = c.nextInt();
        return a;
    }
    public long[] scanArrayL(int n){
        long a[] = new long[n];
        for(int i=0;i<n;i++)
            a[i] = c.nextLong();
        return a;
    }
    public void printArray(long[] a){
        for(int i=0;i<a.length;i++)
            w.print(a[i]+" ");
        w.println();
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt() {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    public static void main(String args[]) throws Exception {
        new Thread(null, new TaskA(),"TaskA",1<<26).start();
    }
}


import java.io.*;
import java.util.*;

public class CF1009E {
	static final int MD = 998244353;
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		int[] aa = new int[1 + n];
		for (int i = 1, a = 0; i <= n; i++)
			aa[i] = a = (a + Integer.parseInt(st.nextToken())) % MD;
		int[] pp = new int[n];
		pp[0] = 1;
		for (int i = 1, p = 1; i < n; i++) {
			pp[i] = p;
			p = p * 2 % MD;
		}
		int d = 0;
		long ans = 0;
		for (int i = n - 1; i >= 0; i--) {	// rest at i
			d = (d * 2 % MD + aa[n - 1 - i]) % MD;	// rest again before n
			ans = (ans + (long) (d + aa[n - i]) * pp[i]) % MD;
		}
		System.out.println(ans);
	}
}