import java.util.TreeMap;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Map;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

 class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.readInt();
        TreeMap<Integer, Integer> a = new TreeMap<Integer, Integer>();
        TreeMap<Integer, Integer> b = new TreeMap<Integer, Integer>();
        for (int i = 0; i < n; i++) {
            int x1 = in.readInt();
            int x2 = in.readInt();
            add(a, x1);
            if (x1 != x2) {
                add(b, x2);
            }
        }
        int need = (n + 1) / 2;
        int ans = (int) 1e9;
        for (Map.Entry<Integer, Integer> e : a.entrySet()) {
            int color = e.getKey();
            int x1 = e.getValue();
            int x2 = get(b, color);
            if (x1 + x2 >= need) {
                ans = Math.min(ans, need - x1);
            }
        }
        if (ans < 0) {
            ans = 0;
        }
        if (ans == (int) 1e9) {
            ans = -1;
        }
        out.printLine(ans);
    }

    private int get(TreeMap<Integer, Integer> map, int x) {
        Integer val = map.get(x);
        if (val == null) {
            return 0;
        }
        return val;
    }

    private void add(TreeMap<Integer, Integer> map, int x) {
        int now = get(map, x);
        map.put(x, now + 1);
    }
}

 class InputReader {

	 private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	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 readInt() {
		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 boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

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

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

 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);
	}
}


import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.util.Arrays;
import java.io.InputStream;
import java.util.Random;
import java.util.Map;
import java.io.OutputStreamWriter;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

 class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.readInt();
        EzIntIntMap a = new EzIntIntHashMap();
        EzIntIntMap b = new EzIntIntHashMap();
        for (int i = 0; i < n; i++) {
            int x1 = in.readInt();
            int x2 = in.readInt();
            add(a, x1, 1);
            add(a, x2, 0);
            if (x1 != x2) {
                add(b, x2, 1);
            }
        }
        int need = (n + 1) / 2;
        int ans = (int) 1e9;
        int[] keys = a.keys();
        int[] values = a.values();
        for (int i = 0; i < keys.length; i++) {
            int color = keys[i];
            int x1 = values[i];
            int x2 = get(b, color);
            if (x1 + x2 >= need) {
                ans = Math.min(ans, need - x1);
            }
        }
        if (ans < 0) {
            ans = 0;
        }
        if (ans == (int) 1e9) {
            ans = -1;
        }
        out.printLine(ans);
    }

    private int get(EzIntIntMap map, int x) {
        int val = map.get(x);
        if (map.returnedNull()) {
            return 0;
        }
        return val;
    }

    private void add(EzIntIntMap map, int x, int d) {
        int now = get(map, x);
        map.put(x, now + d);
    }
}

 class InputReader {

     private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	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 readInt() {
		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 boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

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

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

 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);
	}
}

 interface EzIntIntMap {

    int size();

     int get(int key);

    int put(int key, int value);

     boolean returnedNull();

     int[] keys();

    int[] values();

    EzIntIntMapIterator iterator();

    boolean equals(Object object);

    int hashCode();

    String toString();
}

 class EzIntIntHashMap implements EzIntIntMap {
    private static final int DEFAULT_CAPACITY = 8;
    private static final double ENLARGE_NON_FREE_CELLS_RATIO = 0.5;
     private static final int HASHCODE_INITIAL_VALUE = 0x811c9dc5;
    private static final int HASHCODE_MULTIPLIER = 0x01000193;

    private static final byte FREE = 0;
     private static final byte FILLED = 2;

    private static final int DEFAULT_NULL_VALUE = (new int[1])[0];

    private static final Random rnd = new Random();
    private static final int POS_RANDOM_SHIFT_1;
    private static final int POS_RANDOM_SHIFT_2;
    private static final int STEP_RANDOM_SHIFT_1;
    private static final int STEP_RANDOM_SHIFT_2;

    static {
        POS_RANDOM_SHIFT_1 = rnd.nextInt(10) + 11;
        POS_RANDOM_SHIFT_2 = rnd.nextInt(10) + 21;
        STEP_RANDOM_SHIFT_1 = rnd.nextInt(10) + 11;
        STEP_RANDOM_SHIFT_2 = rnd.nextInt(10) + 21;
    }

    private int[] keys;
    private int[] values;
    private byte[] status;
    private int size;
    private int removedCount;
    private int mask;
    private boolean returnedNull;
    private final int hashSeed;

    public EzIntIntHashMap() {
        this(DEFAULT_CAPACITY);
    }

    public EzIntIntHashMap(int capacity) {
        if (capacity < 0) {
            throw new IllegalArgumentException("Capacity must be non-negative");
        }
        capacity = Math.max(4, (int) (capacity / ENLARGE_NON_FREE_CELLS_RATIO));
        if ((capacity & (capacity - 1)) != 0) {
            capacity = Integer.highestOneBit(capacity) << 1;
        }
        keys = new int[capacity];
        values = new int[capacity];
        status = new byte[capacity];
        size = 0;
        removedCount = 0;
        mask = capacity - 1;
        returnedNull = false;
        hashSeed = rnd.nextInt();
    }

    public EzIntIntHashMap(EzIntIntMap map) {
        this(map.size());
        for (EzIntIntMapIterator it = map.iterator(); it.hasNext(); it.next()) {
            put(it.getKey(), it.getValue());
        }
    }

    public EzIntIntHashMap(Map<Integer, Integer> javaMap) {
        this(javaMap.size());
        for (Map.Entry<Integer, Integer> e : javaMap.entrySet()) {
            put(e.getKey(), e.getValue());
        }
    }

    private int getStartPos(int h) {
        /*h ^= hashSeed;
        h ^= (h >>> POS_RANDOM_SHIFT_1) ^ (h >>> POS_RANDOM_SHIFT_2);
        return h & mask;*/
        return (h * 1000003) & mask;
    }

    private int getStep(int h) {
//        h ^= hashSeed;
//        h ^= (h >>> STEP_RANDOM_SHIFT_1) ^ (h >>> STEP_RANDOM_SHIFT_2);
//        return ((h << 1) | 1) & mask;
        return 1;
    }

    public int size() {
        return size;
    }

     public int get(int key) {
        final int keyHash = PrimitiveHashCalculator.getHash(key);
        int pos = getStartPos(keyHash);
        final int step = getStep(keyHash);
        for (; status[pos] != FREE; pos = (pos + step) & mask) {
            if (status[pos] == FILLED && keys[pos] == key) {
                returnedNull = false;
                return values[pos];
            }
        }
        returnedNull = true;
        return DEFAULT_NULL_VALUE;
    }

    public int put(int key, int value) {
        final int keyHash = PrimitiveHashCalculator.getHash(key);
        int pos = getStartPos(keyHash);
        final int step = getStep(keyHash);
        for (; status[pos] == FILLED; pos = (pos + step) & mask) {
            if (keys[pos] == key) {
                final int oldValue = values[pos];
                values[pos] = value;
                returnedNull = false;
                return oldValue;
            }
        }
        if (status[pos] == FREE) {
            status[pos] = FILLED;
            keys[pos] = key;
            values[pos] = value;
            size++;
            if (size + removedCount > keys.length * ENLARGE_NON_FREE_CELLS_RATIO) {
                rebuild(keys.length * 2);
            }
            returnedNull = true;
            return DEFAULT_NULL_VALUE;
        }
        final int removedPos = pos;
        for (pos = (pos + step) & mask; status[pos] != FREE; pos = (pos + step) & mask) {
            if (status[pos] == FILLED && keys[pos] == key) {
                final int oldValue = values[pos];
                values[pos] = value;
                returnedNull = false;
                return oldValue;
            }
        }
        status[removedPos] = FILLED;
        keys[removedPos] = key;
        values[removedPos] = value;
        size++;
        removedCount--;
        returnedNull = true;
        return DEFAULT_NULL_VALUE;
    }

     public boolean returnedNull() {
        return returnedNull;
    }

     public int[] keys() {
        int[] result = new int[size];
        for (int i = 0, j = 0; i < keys.length; i++) {
            if (status[i] == FILLED) {
                result[j++] = keys[i];
            }
        }
        return result;
    }

    public int[] values() {
        int[] result = new int[size];
        for (int i = 0, j = 0; i < values.length; i++) {
            if (status[i] == FILLED) {
                result[j++] = values[i];
            }
        }
        return result;
    }

    public EzIntIntMapIterator iterator() {
        return new EzIntIntHashMapIterator();
    }

    private void rebuild(int newCapacity) {
        int[] oldKeys = keys;
        int[] oldValues = values;
        byte[] oldStatus = status;
        keys = new int[newCapacity];
        values = new int[newCapacity];
        status = new byte[newCapacity];
        size = 0;
        removedCount = 0;
        mask = newCapacity - 1;
        for (int i = 0; i < oldKeys.length; i++) {
            if (oldStatus[i] == FILLED) {
                put(oldKeys[i], oldValues[i]);
            }
        }
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        EzIntIntHashMap that = (EzIntIntHashMap) o;

        if (size != that.size) {
            return false;
        }
        for (int i = 0; i < keys.length; i++) {
            if (status[i] == FILLED) {
                int thatValue = that.get(keys[i]);
                if (that.returnedNull || thatValue != values[i]) {
                    return false;
                }
            }
        }
        return true;
    }

    private void randomShuffle(int[] array) {
        int n = array.length;
        for (int i = 0; i < n; i++) {
            int j = i + rnd.nextInt(n - i);
            int tmp = array[i];
            array[i] = array[j];
            array[j] = tmp;
        }
    }

    public int hashCode() {
        int[] entryHashes = new int[size];
        for (int i = 0, j = 0; i < status.length; i++) {
            if (status[i] == FILLED) {
                int hash = HASHCODE_INITIAL_VALUE;
                hash = (hash ^ PrimitiveHashCalculator.getHash(keys[i])) * HASHCODE_MULTIPLIER;
                hash = (hash ^ PrimitiveHashCalculator.getHash(values[i])) * HASHCODE_MULTIPLIER;
                entryHashes[j++] = hash;
            }
        }
        randomShuffle(entryHashes);
        Arrays.sort(entryHashes);
        int hash = HASHCODE_INITIAL_VALUE;
        for (int i = 0; i < size; i++) {
            hash = (hash ^ entryHashes[i]) * HASHCODE_MULTIPLIER;
        }
        return hash;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append('{');
        for (int i = 0; i < keys.length; i++) {
            if (status[i] == FILLED) {
                if (sb.length() > 1) {
                    sb.append(", ");
                }
                sb.append(keys[i]);
                sb.append('=');
                sb.append(values[i]);
            }
        }
        sb.append('}');
        return sb.toString();
    }

    private class EzIntIntHashMapIterator implements EzIntIntMapIterator {
        private int curIndex;

        private EzIntIntHashMapIterator() {
            curIndex = 0;
            while (curIndex < status.length && status[curIndex] != FILLED) {
                curIndex++;
            }
        }

        public boolean hasNext() {
            return curIndex < status.length;
        }

        public int getKey() {
            if (curIndex == keys.length) {
                throw new NoSuchElementException("Iterator doesn't have more entries");
            }
            return keys[curIndex];
        }

        public int getValue() {
            if (curIndex == values.length) {
                throw new NoSuchElementException("Iterator doesn't have more entries");
            }
            return values[curIndex];
        }

        public void next() {
            if (curIndex == status.length) {
                return;
            }
            curIndex++;
            while (curIndex < status.length && status[curIndex] != FILLED) {
                curIndex++;
            }
        }
    }
}

interface EzIntIntMapIterator {
    boolean hasNext();

    int getKey();

    int getValue();

    void next();
}

final class PrimitiveHashCalculator {
    private PrimitiveHashCalculator() {
    }

    public static int getHash(int x) {
        return x;
    }

}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.HashMap;
import java.util.HashSet;
import java.util.TreeSet;

public class A {

    public static void main(String[] args) throws Exception {
        HashMap<Integer, int[]> hm = new HashMap<Integer, int[]>();
        HashSet<Integer> hs = new HashSet<Integer>();

        int n = nextInt();

        for(int i = 0; i<n; i++) {
            int a = nextInt(), b = nextInt();

            if(hs.contains(a)) {
                hm.get(a)[0]++;
            } else {
                hs.add(a);
                hm.put(a, new int[] {1, 0});
            }

            if(b != a) {
                if(hs.contains(b)) {
                    hm.get(b)[1]++;
                } else {
                    hs.add(b);
                    hm.put(b, new int[] {0, 1});
                }
            }
        }

        int min = INF;
        for(int a : hs) {
            int[] cur = hm.get(a);

            if(cur[0] + cur[1] >= (n+1)/2) {
                int curr = Math.max(0, (n+1)/2 - cur[0]);
                if(curr < min)
                    min = curr;
            }
        }
        println(min == INF ? -1 : min);
    }

    /////////////////////////////////////////////////////////////////
    // IO
    /////////////////////////////////////////////////////////////////
    private static StreamTokenizer in;
    private static PrintWriter out;
    private static BufferedReader inB;

    private static boolean FILE=false;

    private static int nextInt() throws Exception{
        in.nextToken();
        return (int)in.nval;
    }

    private static String nextString() throws Exception{
        in.nextToken();
        return in.sval;
    }

    static{
        try {
            out = new PrintWriter(FILE ? (new FileOutputStream("output.txt")) : System.out);
            inB = new BufferedReader(new InputStreamReader(FILE ? new FileInputStream("input.txt") : System.in));
        } catch(Exception e) {e.printStackTrace();}
        in = new StreamTokenizer(inB);
    }
    /////////////////////////////////////////////////////////////////

    /////////////////////////////////////////////////////////////////
    // pre - written
    /////////////////////////////////////////////////////////////////
    private static void println(Object o) throws Exception {
        out.println(o);
        out.flush();
    }
    private static void exit(Object o) throws Exception {
        println(o);
        exit();
    }
    private static void exit() {
        System.exit(0);
    }
    private static final int  INF = Integer.MAX_VALUE;
    private static final int MINF = Integer.MIN_VALUE;
    //////////////////////////////////////////////////////////////////
}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.HashMap;
import java.util.HashSet;
import java.util.TreeSet;

public class A {

    public static void main(String[] args) throws Exception {
        HashMap<Integer, int[]> hm = new HashMap<Integer, int[]>();
        TreeSet<Integer> hs = new TreeSet<Integer>();

        int n = nextInt();

        for(int i = 0; i<n; i++) {
            int a = nextInt(), b = nextInt();

            if(hs.contains(a)) {
                hm.get(a)[0]++;
            } else {
                hs.add(a);
                hm.put(a, new int[] {1, 0});
            }

            if(b != a) {
                if(hs.contains(b)) {
                    hm.get(b)[1]++;
                } else {
                    hs.add(b);
                    hm.put(b, new int[] {0, 1});
                }
            }
        }

        int min = INF;
        for(int a : hs) {
            int[] cur = hm.get(a);

            if(cur[0] + cur[1] >= (n+1)/2) {
                int curr = Math.max(0, (n+1)/2 - cur[0]);
                if(curr < min)
                    min = curr;
            }
        }
        println(min == INF ? -1 : min);
    }

    /////////////////////////////////////////////////////////////////
    // IO
    /////////////////////////////////////////////////////////////////
    private static StreamTokenizer in;
    private static PrintWriter out;
    private static BufferedReader inB;

    private static boolean FILE=false;

    private static int nextInt() throws Exception{
        in.nextToken();
        return (int)in.nval;
    }

    private static String nextString() throws Exception{
        in.nextToken();
        return in.sval;
    }

    static{
        try {
            out = new PrintWriter(FILE ? (new FileOutputStream("output.txt")) : System.out);
            inB = new BufferedReader(new InputStreamReader(FILE ? new FileInputStream("input.txt") : System.in));
        } catch(Exception e) {e.printStackTrace();}
        in = new StreamTokenizer(inB);
    }
    /////////////////////////////////////////////////////////////////

    /////////////////////////////////////////////////////////////////
    // pre - written
    /////////////////////////////////////////////////////////////////
    private static void println(Object o) throws Exception {
        out.println(o);
        out.flush();
    }
    private static void exit(Object o) throws Exception {
        println(o);
        exit();
    }
    private static void exit() {
        System.exit(0);
    }
    private static final int  INF = Integer.MAX_VALUE;
    private static final int MINF = Integer.MIN_VALUE;
    //////////////////////////////////////////////////////////////////
}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class A {

    public static void main(String[] args) throws Exception {
        TreeMap<Integer, int[]> hm = new TreeMap<Integer, int[]>();
        TreeSet<Integer> hs = new TreeSet<Integer>();

        int n = nextInt();

        for(int i = 0; i<n; i++) {
            int a = nextInt(), b = nextInt();

            if(hs.contains(a)) {
                hm.get(a)[0]++;
            } else {
                hs.add(a);
                hm.put(a, new int[] {1, 0});
            }

            if(b != a) {
                if(hs.contains(b)) {
                    hm.get(b)[1]++;
                } else {
                    hs.add(b);
                    hm.put(b, new int[] {0, 1});
                }
            }
        }

        int min = INF;
        for(int a : hs) {
            int[] cur = hm.get(a);

            if(cur[0] + cur[1] >= (n+1)/2) {
                int curr = Math.max(0, (n+1)/2 - cur[0]);
                if(curr < min)
                    min = curr;
            }
        }
        println(min == INF ? -1 : min);
    }

    /////////////////////////////////////////////////////////////////
    // IO
    /////////////////////////////////////////////////////////////////
    private static StreamTokenizer in;
    private static PrintWriter out;
    private static BufferedReader inB;

    private static boolean FILE=false;

    private static int nextInt() throws Exception{
        in.nextToken();
        return (int)in.nval;
    }

    private static String nextString() throws Exception{
        in.nextToken();
        return in.sval;
    }

    static{
        try {
            out = new PrintWriter(FILE ? (new FileOutputStream("output.txt")) : System.out);
            inB = new BufferedReader(new InputStreamReader(FILE ? new FileInputStream("input.txt") : System.in));
        } catch(Exception e) {e.printStackTrace();}
        in = new StreamTokenizer(inB);
    }
    /////////////////////////////////////////////////////////////////

    /////////////////////////////////////////////////////////////////
    // pre - written
    /////////////////////////////////////////////////////////////////
    private static void println(Object o) throws Exception {
        out.println(o);
        out.flush();
    }
    private static void exit(Object o) throws Exception {
        println(o);
        exit();
    }
    private static void exit() {
        System.exit(0);
    }
    private static final int  INF = Integer.MAX_VALUE;
    private static final int MINF = Integer.MIN_VALUE;
    //////////////////////////////////////////////////////////////////
}


#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int a[300005];

struct data
{
    int w;
    int pos;
}d[300005];

int cmp(data a,data b)
{
    return a.w<b.w;
}

int rct[300005],tot[300005];

int main()
{
    int n;
    scanf("%d",&n);

    for(int i=0;i<2*n;i++)
    {
        scanf("%d",&a[i]);
        d[i].pos=i;
        d[i].w=a[i];
    }

    sort(d,d+2*n,cmp);

    memset(rct,0,sizeof(rct));

    int cnt=0;
    a[d[0].pos]=0;
    for(int i=1;i<2*n;i++)
    {
        if(d[i].w>d[i-1].w) cnt++;
        a[d[i].pos]=cnt;
    }

    for(int i=0;i<2*n;i+=2)
    {
        rct[a[i]]++;
        if(a[i]!=a[i+1])
        {
            tot[a[i]]++;
            tot[a[i+1]]++;
        }
    }

    int ans=200000000;
    for(int i=0;i<300000;i++)
       if(tot[i]*2<n) continue;
       else
       {
           int sum=(n+1)/2;
           if(sum-rct[i]<ans) ans=sum-rct[i];
       }

    if(ans==200000000) ans=-1;
    printf("%d\n",ans);
}


#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int a[300005];

struct data
{
    int w;
    int pos;
}d[300005];

int cmp(data a,data b)
{
    return a.w<b.w;
}

int rct[300005],tot[300005];

int main()
{
    int n;
    scanf("%d",&n);

    for(int i=0;i<2*n;i++)
    {
        scanf("%d",&a[i]);
        d[i].pos=i;
        d[i].w=a[i];
    }

    sort(d,d+2*n,cmp);

    memset(rct,0,sizeof(rct));
    memset(tot,0,sizeof(tot));

    int cnt=0;
    a[d[0].pos]=0;
    for(int i=1;i<2*n;i++)
    {
        if(d[i].w>d[i-1].w) cnt++;
        a[d[i].pos]=cnt;
    }

    for(int i=0;i<2*n;i+=2)
    {
        rct[a[i]]++;
        if(a[i]!=a[i+1])
        {
            tot[a[i]]++;
            tot[a[i+1]]++;
        }
        else tot[a[i]]++;
    }

    int ans=200000000;
    for(int i=0;i<300000;i++)
       if(tot[i]*2<n) continue;
       else
       {
           int sum=(n+1)/2;
           if(sum-rct[i]<ans) ans=sum-rct[i];
       }

    if(ans<0) ans=0;
    if(ans==200000000) ans=-1;
    printf("%d\n",ans);
}


#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int a[300005];

struct data
{
    int w;
    int pos;
}d[300005];

int cmp(data a,data b)
{
    return a.w<b.w;
}

int rct[300005],tot[300005];

int main()
{
    int n;
    scanf("%d",&n);

    for(int i=0;i<2*n;i++)
    {
        scanf("%d",&a[i]);
        d[i].pos=i;
        d[i].w=a[i];
    }

    sort(d,d+2*n,cmp);

    memset(rct,0,sizeof(rct));

    int cnt=0;
    if(d[0].pos%2==0) rct[cnt]++;
    tot[cnt]++;
    for(int i=1;i<2*n;i++)
    {
        if(d[i].w>d[i-1].w) cnt++;
        if(d[i].pos%2==0) rct[cnt]++;
        tot[cnt]++;
    }

    int ans=200000000;
    for(int i=0;i<300000;i++)
       if(tot[i]*2<n) continue;
       else
       {
           int sum=(n+1)/2;
           if(sum-rct[i]<ans) ans=sum-rct[i];
       }

    if(ans==200000000) ans=-1;
    printf("%d\n",ans);
}


#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int a[300005];

struct data
{
    int w;
    int pos;
}d[300005];

int cmp(data a,data b)
{
    return a.w<b.w;
}

int rct[300005],tot[300005];

int main()
{
    int n;
    scanf("%d",&n);

    for(int i=0;i<2*n;i++)
    {
        scanf("%d",&a[i]);
        d[i].pos=i;
        d[i].w=a[i];
    }

    sort(d,d+2*n,cmp);

    memset(rct,0,sizeof(rct));

    int cnt=0;
    a[d[0].pos]=0;
    for(int i=1;i<2*n;i++)
    {
        if(d[i].w>d[i-1].w) cnt++;
        a[d[i].pos]=cnt;
    }

    for(int i=0;i<2*n;i+=2)
    {
        rct[a[i]]++;
        if(a[i]!=a[i+1])
        {
            tot[a[i]]++;
            tot[a[i+1]]++;
        }
        else tot[a[i]]++;
    }

    int ans=200000000;
    for(int i=0;i<300000;i++)
       if(tot[i]*2<n) continue;
       else
       {
           int sum=(n+1)/2;
           if(sum-rct[i]<ans) ans=sum-rct[i];
       }

    if(ans==200000000) ans=-1;
    printf("%d\n",ans);
}


#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int a[300005];

struct data
{
    int w;
    int pos;
}d[300005];

int cmp(data a,data b)
{
    return a.w<b.w;
}

int rct[300005],tot[300005];

int main()
{
    int n;
    scanf("%d",&n);

    for(int i=0;i<2*n;i++)
    {
        scanf("%d",&a[i]);
        d[i].pos=i;
        d[i].w=a[i];
    }

    sort(d,d+2*n,cmp);

    memset(rct,0,sizeof(rct));

    int cnt=0;
    if(d[0].pos%2==0) rct[cnt]++;
    tot[cnt]++;
    for(int i=1;i<2*n;i++)
    {
        if(d[i].w>d[i-1].w) cnt++;
        if(d[i].pos%2==0) rct[cnt]++;
        tot[cnt]++;
    }

    int ans=200000000;
    for(int i=0;i<300000;i++)
       if(tot[i]*2<n) continue;
       else
       {
           int sum=(n+1)/2;
           if(sum-rct[i]<ans) ans=sum-rct[i];
       }

    printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
map <int, int> P, Q;
vector <int> V;
int main() {
    int n, x, y;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d%d", &x, &y);
        P[x]++; Q[y]++;
        V.push_back(x);
        V.push_back(y);
    }
    int u = n / 2 + (n % 2);
    int ans = 0x7fffffff;
    for(int i = 0; i < V.size(); i++) {
        int t = V[i];
        int p = P[t], q = Q[t];
        if(p + q >= u) {
            ans = min(ans, u - p);
        }
    }
    if(ans == 0x7fffffff) printf("-1\n"); else printf("%d\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
map <int, int> P, Q, R;
vector <int> V;
int main() {
    int n, x, y;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d%d", &x, &y);
        P[x]++; Q[y]++;
        V.push_back(x);
        V.push_back(y);
        if(x == y) R[x]++;
    }
    int u = n / 2 + (n % 2);
    int ans = 0x7fffffff;
    for(int i = 0; i < V.size(); i++) {
        int t = V[i];
        int p = P[t], q = Q[t], r = R[t];
        if(p + q - r >= u) {
            ans = max(0, min(ans, u - p));
        }
    }
    if(ans == 0x7fffffff) printf("-1\n"); else printf("%d\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
map <int, int> P, Q;
vector <int> V;
int main() {
    int n, x, y;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d%d", &x, &y);
        P[x]++; Q[y]++;
        V.push_back(x);
        V.push_back(y);
    }
    int u = n / 2 + (n % 2);
    int ans = 0x7fffffff;
    for(int i = 0; i < V.size(); i++) {
        int t = V[i];
        int p = P[t], q = Q[t];
        if(p + q >= u) {
            ans = max(0, min(ans, u - p));
        }
    }
    if(ans == 0x7fffffff) printf("-1\n"); else printf("%d\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
map <int, int> P, Q;
vector <int> V;
int main() {
    int n, x, y;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d%d", &x, &y);
        P[x]++; Q[y]++;
        V.push_back(x);
        V.push_back(y);
    }
    int u = n / 2 + (n % 2);
    int ans = 0x7fffffff;
    for(int i = 0; i < V.size(); i++) {
        int t = V[i];
        int p = P[t], q = Q[t];
        if(p + q >= u) {
            ans = min(ans, u - p);
        }
    }
    printf("%d\n", ans);
    return 0;
}


#include <cstdio>
#include <map>

using namespace std;

map<int,int> front,back;

int main(int argc, char const *argv[])
{
	int n,f,b;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d %d",&f,&b);
		front[f]++;
		back[b]++;
	}
	int beautiful = (n+1)/2;
	int minimum = n+100;
	for (map<int,int>::iterator it=front.begin(); it!=front.end(); ++it)
	{
		if(it->second >= beautiful)
		{
			minimum = 0;
		}
		else if(back.count(it->first)>0)
		{
			if( back[ it->first ] + it->second >= beautiful)
			{
				minimum = min(minimum,beautiful - it->second);
			}
		}
	}

	printf("%d\n",minimum );
	return 0;
}


#include <cstdio>
#include <map>

using namespace std;

map<int,int> front,back;

int main(int argc, char const *argv[])
{
	int n,f,b;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d %d",&f,&b);
		front[f]++;
		back[b]++;
	}
	int beautiful = (n+1)/2;
	int minimum = 999999;
	for (map<int,int>::iterator it=front.begin(); it!=front.end(); ++it)
	{
		if(it->second >= beautiful)
		{
			minimum = 0;
		}
		else if(back.count(it->first)>0)
		{
			if( back[ it->first ] + it->second >= beautiful)
			{
				minimum = min(minimum,beautiful - it->second);
			}
		}
	}
	if(minimum<999999)
		printf("%d\n",minimum );
	else
		printf("-1\n");
	return 0;
}


#include <cstdio>
#include <map>

using namespace std;

map<int,int> front,back;

int main(int argc, char const *argv[])
{
	int n,f,b;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d %d",&f,&b);
		front[f]++;
		if(f!=b)
			back[b]++;
	}
	int beautiful = (n+1)/2;
	int minimum = 999999;
	for (map<int,int>::iterator it=front.begin(); it!=front.end(); ++it)
	{
		if(it->second >= beautiful)
		{
			minimum = 0;
		}
		else if(back.count(it->first)>0)
		{
			if( back[ it->first ] + it->second >= beautiful)
			{
				minimum = min(minimum,beautiful - it->second);
			}
		}
	}
	for (map<int,int>::iterator it=back.begin(); it!=back.end(); ++it)
	{
		if(it->second >= beautiful)
		{
			minimum = min(minimum,beautiful);
		}
	}
	if(minimum<999999)
		printf("%d\n",minimum );
	else
		printf("-1\n");
	return 0;
}


#include <cstdio>
#include <map>

using namespace std;

map<int,int> front,back;

int main(int argc, char const *argv[])
{
	int n,f,b;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d %d",&f,&b);
		front[f]++;
		if(f!=b)
			back[b]++;
	}
	int beautiful = (n+1)/2;
	int minimum = 999999;
	for (map<int,int>::iterator it=front.begin(); it!=front.end(); ++it)
	{
		if(it->second >= beautiful)
		{
			minimum = 0;
		}
		else if(back.count(it->first)>0)
		{
			if( back[ it->first ] + it->second >= beautiful)
			{
				minimum = min(minimum,beautiful - it->second);
			}
		}
	}
	if(minimum<999999)
		printf("%d\n",minimum );
	else
		printf("-1\n");
	return 0;
}


#include <cstdio>
#include <map>

using namespace std;

map<int,int> front,back;

int main(int argc, char const *argv[])
{
	int n,f,b;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d %d",&f,&b);
		front[f]++;
		if(f!=b)
			back[b]++;
	}
	int beautiful = (n+1)/2;
	int minimum = 999999;
	for (map<int,int>::iterator it=front.begin(); it!=front.end(); ++it)
	{
		if(it->second >= beautiful)
		{
			minimum = 0;
		}
		else if(back.count(it->first)>0)
		{
			if( back[ it->first ] + it->second >= beautiful)
			{
				minimum = min(minimum,beautiful - it->second);
			}
		}
	}
	for (map<int,int>::iterator it=back.begin(); it!=back.end(); ++it)
	{
		if(it->second >= beautiful)
		{
			minimum = beautiful;
		}
	}
	if(minimum<999999)
		printf("%d\n",minimum );
	else
		printf("-1\n");
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <map>
#include <vector>
#include <set>
using namespace std;
int mmin(int a , int b){
	if(a<b)
		return a;
	return b;
}
int main(){
std::map<int, int> up;
std::map<int, int> down;
set<int> checker;
int N , x , y , T;
scanf("%d",&N);
int ans = 10000000;
T = N;
int half = (N/2) + N%2;
while(T--){
cin >> x >> y;
up[x] += 1;
down[y]+=1;
if(up[x]+down[x] >= half)
	checker.insert(x);
if(up[y]+down[y] >= half)
	checker.insert(y);
if(up[x]>=half)
	ans = 0;
}
set<int>::iterator it = checker.begin();
//cout << down[7] << endl;
if(checker.size() == 0)
{
	printf("-1\n");
	return 0;
}
while(it!=checker.end()){
//cout << *it << endl;
ans = min(ans , down[*it]);
it++;
}
printf("%d\n", ans);
return 0;
}


#include <iostream>
#include <stdio.h>
#include <map>
#include <vector>
#include <set>
using namespace std;
int mmin(int a , int b){
	if(a<b)
		return a;
	return b;
}
int main(){
std::map<int, int> up;
std::map<int, int> down;
set<int> checker;
int N , x , y , T;
scanf("%d",&N);
int ans = 10000000;
T = N;
int half = ((N+1)/2);

while(T--)
{
cin >> x >> y;
up[x] += 1;
if(x!=y)
down[y]+=1;
checker.insert(x);
checker.insert(y);
}

set<int>::iterator it = checker.begin();

int flag = 0;

while(it!=checker.end())
{
if(up[*it]>=half)
{
	flag = 1;
	ans = 0;
	it++;
	continue;
}
if(up[*it]+down[*it]>=half)
{
	//cout << " * " << endl;
	//cout << *it << endl;
	flag = 1;
	ans = min(ans , down[*it]);
}
it++;
}

if(flag==1)
printf("%d\n", ans);
else
printf("-1\n");
return 0;
}


#include <iostream>
#include <stdio.h>
#include <map>
#include <vector>
#include <set>
using namespace std;
int mmin(int a , int b){
	if(a<b)
		return a;
	return b;
}
int main(){
std::map<int, int> up;
std::map<int, int> down;
set<int> checker;
int N , x , y , T;
scanf("%d",&N);
int ans = 10000000;
T = N;
int half = (N/2) + N%2;
while(T--){
cin >> x >> y;
up[x] += 1;
down[y]+=1;
if(up[x]+down[x] >= half)
	checker.insert(x);
if(up[y]+down[y] >= half)
	checker.insert(y);
if(up[x]>=half)
	ans = 0;
}
set<int>::iterator it = checker.begin();
//cout << down[7] << endl;
while(it!=checker.end()){
//cout << *it << endl;
ans = min(ans , down[*it]);
it++;
}
printf("%d\n", ans);
return 0;
}


#include <iostream>
#include <stdio.h>
#include <map>
#include <vector>
#include <set>
using namespace std;
int mmin(int a , int b){
	if(a<b)
		return a;
	return b;
}
int main(){
std::map<int, int> up;
std::map<int, int> down;
set<int> checker;
int N , x , y , T;
scanf("%d",&N);
int ans = 10000000;
T = N;
int half = ((N+1)/2);

while(T--)
{
cin >> x >> y;
up[x] += 1;
if(x!=y)
down[y]+=1;
checker.insert(x);
checker.insert(y);
}

set<int>::iterator it = checker.begin();

int flag = 0;

while(it!=checker.end())
{
if(up[*it]>=half)
{
	flag = 1;
	ans = 0;
	it++;
	continue;
}
if(up[*it]+down[*it]>=half)
{
	//cout << " * " << endl;
	//cout << *it << endl;
	flag = 1;
	ans = min(ans , half - up[*it]);
}
it++;
}

if(flag==1)
printf("%d\n", ans);
else
printf("-1\n");
return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <cstring>
using namespace std;
#define rep(i, n) for (int (i) = 0, j1234 = n; (i) < j1234; (i) ++)
#define rep1(i, n) for (int (i) = 1, j1234 = n; (i) <= j1234; (i) ++)
#define For(i, a, b) for (int (i) = (a), ub1234=b; (i) <= ub1234; (i) ++)
#define db(x) {if(debug){cout << #x << " = " << (x) << endl;}}
#define dba(a, x, y) {if(debug){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}}
#define mp make_pair
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const int output_precision = 15;
const bool debug = true;
// const ll MOD = ;

stringstream ss;
map<int,int> cnt_front;
map<int,int> cnt_back;
int N;
vector<int> numbers;
int main()
{
  ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;
  ss.precision(output_precision); ss << fixed;
  cin >> N;
  rep1(i,N)
  {
    int foo, bar;
    cin >> foo >> bar;
    cnt_front[foo]++;
    if (foo != bar) cnt_back[bar]++;
    numbers.pb(foo);
//    if (foo!=bar) numbers.pb(bar);
    numbers.pb(bar);
  }
//  sort(numbers.begin(), numbers.end());
//  numbers.erase( unique(numbers.begin(),numbers.end()), numbers.end());
//  dba(numbers,0,numbers.size()-1);
  int ans = INF;
  rep(i, numbers.size())
  {
    int n = numbers[i];
    int num_to_flip=((N+1)>>1)-cnt_front[n];
//    if (n == 1)
//    {
//      db(num_to_flip);
//      db(cnt_front[n]);
//      db(cnt_back[n]);
//    }
    if (num_to_flip > cnt_back[n])
      continue;
    ans = min(ans,num_to_flip);
  }
  if (ans == INF)
    ans = -1;
  cout << ans << endl;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <cstring>
using namespace std;
#define rep(i, n) for (int (i) = 0, j1234 = n; (i) < j1234; (i) ++)
#define rep1(i, n) for (int (i) = 1, j1234 = n; (i) <= j1234; (i) ++)
#define For(i, a, b) for (int (i) = (a), ub1234=b; (i) <= ub1234; (i) ++)
#define db(x) {if(debug){cout << #x << " = " << (x) << endl;}}
#define dba(a, x, y) {if(debug){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}}
#define mp make_pair
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const int output_precision = 15;
const bool debug = true;
// const ll MOD = ;

stringstream ss;
map<int,int> cnt_front;
map<int,int> cnt_back;
int N;
vector<int> numbers;
int main()
{
  ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;
  ss.precision(output_precision); ss << fixed;
  cin >> N;
  rep1(i,N)
  {
    int foo, bar;
    cin >> foo >> bar;
    cnt_front[foo]++;
    cnt_back[bar]++;
    numbers.pb(foo);
    numbers.pb(bar);
  }
  sort(numbers.begin(), numbers.end());
  numbers.erase( unique(numbers.begin(),numbers.end()), numbers.end());
  int ans = INF;
  rep(i, numbers.size())
  {
    int n = numbers[i];
    int num_to_flip=((N+1)>>1)-cnt_front[n];
    if (num_to_flip > cnt_back[n])
      continue;
    ans = min(ans,num_to_flip);
  }
  assert(ans != INF);
  cout << ans << endl;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <cstring>
using namespace std;
#define rep(i, n) for (int (i) = 0, j1234 = n; (i) < j1234; (i) ++)
#define rep1(i, n) for (int (i) = 1, j1234 = n; (i) <= j1234; (i) ++)
#define For(i, a, b) for (int (i) = (a), ub1234=b; (i) <= ub1234; (i) ++)
#define db(x) {if(debug){cout << #x << " = " << (x) << endl;}}
#define dba(a, x, y) {if(debug){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}}
#define mp make_pair
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const int output_precision = 15;
const bool debug = true;
// const ll MOD = ;

stringstream ss;
map<int,int> cnt_front;
map<int,int> cnt_back;
int N;
vector<int> numbers;
int main()
{
  ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;
  ss.precision(output_precision); ss << fixed;
  cin >> N;
  rep1(i,N)
  {
    int foo, bar;
    cin >> foo >> bar;
    cnt_front[foo]++;
    if (foo != bar) cnt_back[bar]++;
    numbers.pb(foo);
//    if (foo!=bar) numbers.pb(bar);
    numbers.pb(bar);
  }
  sort(numbers.begin(), numbers.end());
  numbers.erase( unique(numbers.begin(),numbers.end()), numbers.end());
  int ans = INF;
  rep(i, numbers.size())
  {
    int n = numbers[i];
    int num_to_flip=((N+1)>>1)-cnt_front[n];
    if (num_to_flip > cnt_back[n])
      continue;
    ans = min(ans,num_to_flip);
  }
  if (ans == INF)
    ans = -1;
  cout << ans << endl;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <cstring>
using namespace std;
#define rep(i, n) for (int (i) = 0, j1234 = n; (i) < j1234; (i) ++)
#define rep1(i, n) for (int (i) = 1, j1234 = n; (i) <= j1234; (i) ++)
#define For(i, a, b) for (int (i) = (a), ub1234=b; (i) <= ub1234; (i) ++)
#define db(x) {if(debug){cout << #x << " = " << (x) << endl;}}
#define dba(a, x, y) {if(debug){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}}
#define mp make_pair
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const int output_precision = 15;
const bool debug = true;
// const ll MOD = ;

stringstream ss;
map<int,int> cnt_front;
map<int,int> cnt_back;
int N;
vector<int> numbers;
int main()
{
  ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;
  ss.precision(output_precision); ss << fixed;
  cin >> N;
  rep1(i,N)
  {
    int foo, bar;
    cin >> foo >> bar;
    cnt_front[foo]++;
    if (foo != bar) cnt_back[bar]++;
    numbers.pb(foo);
//    if (foo!=bar) numbers.pb(bar);
    numbers.pb(bar);
  }
//  sort(numbers.begin(), numbers.end());
//  numbers.erase( unique(numbers.begin(),numbers.end()), numbers.end());
//  dba(numbers,0,numbers.size()-1);
  int ans = INF;
  rep(i, numbers.size())
  {
    int n = numbers[i];
    int num_to_flip=((N+1)>>1)-cnt_front[n];
    if (num_to_flip < 0) num_to_flip=0;
//    if (n == 1)
//    {
//      db(num_to_flip);
//      db(cnt_front[n]);
//      db(cnt_back[n]);
//    }
    if (num_to_flip > cnt_back[n])
      continue;
    ans = min(ans,num_to_flip);
  }
  if (ans == INF)
    ans = -1;
  cout << ans << endl;
}


#include <algorithm>
#include <iostream>
#include <climits>
#include <list>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i < (int)(e); i++)

int main() {
    int N;
    cin >> N;

    int a, b;
    set<long long int> color;
    map<long long int, int> up;
    map<long long int, int> down;
    REP(i, N) {
	cin >> a >> b;
	color.insert(a);
	color.insert(b);
	up[a]++;
	down[b]++;
    }

    int ret = 2*N;
    for (typeof((color).begin()) itr = (color).begin(); (itr) != (color).end(); (itr)++) {
	long long int x = *itr;
	int y = up.count(x) ? up[x] : 0;
	int z = down.count(x) ? down[x] : 0;

	if (2*(y+z) >= N) {
	    int rm = N - N/2 - y;
	    rm = max(rm, 0);
	    if (rm >= z)
		ret = min(ret, rm);
	}
    }
    if (ret == 2*N)
	ret = -1;
    cout << ret << endl;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <climits>
#include <list>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i < (int)(e); i++)

int main() {
    int N;
    cin >> N;

    int a, b;
    set<long long int> color;
    map<long long int, int> up;
    map<long long int, int> down;
    REP(i, N) {
	cin >> a >> b;
	color.insert(a);
	color.insert(b);
	up[a]++;
	if (a != b)
	    down[b]++;
    }

    int ret = 2*N;
    for (typeof((color).begin()) itr = (color).begin(); (itr) != (color).end(); (itr)++) {
	long long int x = *itr;
	int y = up.count(x) ? up[x] : 0;
	int z = down.count(x) ? down[x] : 0;

	if (2*(y+z) >= N) {
	    int rm = N - N/2 - y;
	    rm = max(rm, 0);
	    if (rm <= z)
		ret = min(ret, rm);
	}
    }
    if (ret == 2*N)
	ret = -1;
    cout << ret << endl;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <climits>
#include <list>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i < (int)(e); i++)

int main() {
    int N;
    cin >> N;

    int a, b;
    set<long long int> color;
    map<long long int, int> up;
    map<long long int, int> down;
    REP(i, N) {
	cin >> a >> b;
	color.insert(a);
	color.insert(b);
	up[a]++;
	down[b]++;
    }

    int ret = N;
    for (typeof((color).begin()) itr = (color).begin(); (itr) != (color).end(); (itr)++) {
	long long int x = *itr;
	int y = up[x];
	int z = down[x];

	if (2*(y+z) >= N) {
	    int rm = N - N/2 - y;
	    rm = max(rm, 0);
	    ret = min(ret, rm);
	}
    }

    cout << ret << endl;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <climits>
#include <list>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i < (int)(e); i++)

int main() {
    int N;
    cin >> N;

    int a, b;
    set<long long int> color;
    map<long long int, int> up;
    map<long long int, int> down;
    REP(i, N) {
	cin >> a >> b;
	color.insert(a);
	color.insert(b);
	up[a]++;
	down[b]++;
    }

    int ret = 2*N;
    for (typeof((color).begin()) itr = (color).begin(); (itr) != (color).end(); (itr)++) {
	long long int x = *itr;
	int y = up[x];
	int z = down[x];

	if (2*(y+z) >= N) {
	    int rm = N - N/2 - y;
	    rm = max(rm, 0);
	    ret = min(ret, rm);
	}
    }
    if (ret == 2*N)
	ret = -1;
    cout << ret << endl;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <climits>
#include <list>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i < (int)(e); i++)

int main() {
    int N;
    cin >> N;

    int a, b;
    set<long long int> color;
    map<long long int, int> up;
    map<long long int, int> down;
    REP(i, N) {
	cin >> a >> b;
	color.insert(a);
	color.insert(b);
	up[a]++;
	down[b]++;
    }

    int ret = 2*N;
    for (typeof((color).begin()) itr = (color).begin(); (itr) != (color).end(); (itr)++) {
	long long int x = *itr;
	int y = up.count(x) ? up[x] : 0;
	int z = down.count(x) ? down[x] : 0;

	if (2*(y+z) >= N) {
	    int rm = N - N/2 - y;
	    rm = max(rm, 0);
	    if (rm <= z)
		ret = min(ret, rm);
	}
    }
    if (ret == 2*N)
	ret = -1;
    cout << ret << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,ans=1e9;
map <int,int> up,ng;
int main(){
    ios_base:: sync_with_stdio(0);
    cin>>n;
    int need=n/2 + (n%2);
    for(int i=1;i<=n;i++){
        int a,b; cin>>a>>b;
        ng[a]++ , up[b]++;
        //cout<<a<<' '<<ng[a]<<' '<<up[a]<<endl;
        if(ng[a]+up[a]>=need) {
            int z=max(need-ng[a],0);
            ans=min(ans,z);
        }
        //cout<<b<<' '<<ng[b]<<' '<<up[b]<<endl;
        if(ng[b]+up[b]>=need) {
            int z=max(need-ng[b],0);
            ans=min(ans,z);
        }
    }
    if(ans!=1e9) cout<<ans;
    else cout<<-1;
}


3
1 1
2 5
3 6
#include<bits/stdc++.h>
using namespace std;
int n,ans=1e9;
map <int,int> up,ng;
int main(){
    ios_base:: sync_with_stdio(0);
    cin>>n;
    int need=n/2 + (n%2);
    for(int i=1;i<=n;i++){
        int a,b; cin>>a>>b;
        ng[a]++;
        if(a!=b) up[b]++;
        //cout<<a<<' '<<ng[a]<<' '<<up[a]<<endl;
        if(ng[a]+up[a]>=need) {
            int z=max(need-ng[a],0);
            ans=min(ans,z);
        }
        //cout<<b<<' '<<ng[b]<<' '<<up[b]<<endl;
        if(ng[b]+up[b]>=need) {
            int z=max(need-ng[b],0);
            ans=min(ans,z);
        }
    }
    if(ans!=1e9) cout<<ans;
    else cout<<-1;
}


#include<bits/stdc++.h>
using namespace std;
int n,ans=1e9;
map <int,int> up,ng;
int main(){
    ios_base:: sync_with_stdio(0);
    cin>>n;
    int need=n/2 + (n%2);
    for(int i=1;i<=n;i++){
        int a,b; cin>>a>>b;
        ng[a]++;
        if(a!=b) up[b]++;
        //cout<<a<<' '<<ng[a]<<' '<<up[a]<<endl;
        if(ng[a]+up[a]>=need) {
            int z=max(need-ng[a],0);
            ans=min(ans,z);
        }
        //cout<<b<<' '<<ng[b]<<' '<<up[b]<<endl;
        if(ng[b]+up[b]>=need) {
            int z=max(need-ng[b],0);
            ans=min(ans,z);
        }
    }
    if(ans!=1e9) cout<<ans;
    else cout<<-1;
}


#include<bits/stdc++.h>
using namespace std;
int n,ans=1e9;
map <int,int> up,ng;
int main(){
    ios_base:: sync_with_stdio(0);
    cin>>n;
    int need=n/2 + (n%2);
    for(int i=1;i<=n;i++){
        int a,b; cin>>a>>b;
        ng[a]++ , up[b]++;
        //cout<<a<<' '<<ng[a]<<' '<<up[a]<<endl;
        if(ng[a]+up[a]>=need) {
            int z=max(need-ng[a],0);
            ans=min(ans,z);
        }
        //cout<<b<<' '<<ng[b]<<' '<<up[b]<<endl;
        if(ng[b]+up[b]>=need) {
            int z=max(need-ng[b],0);
            ans=min(ans,z);
        }
    }
    cout<<ans;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<map>
#include<utility>
#include<cmath>
#include<sstream>
#include<fstream>
#include<bitset>
#include<numeric>
using namespace std;
#define hangdiana
#ifndef hangdian
  typedef long  long ll;
#endif
#ifdef hangdian
typedef __int64 ll;
#endif
#define pb(v) push_back(v)
#define FUCK cout<<"fuck"<<endl
void openfile()
{
#if 0
    freopen("input.txt","r", stdin);
    //freopen("output.txt","w",stdout);
#endif
}
#define NL puts("")
#define lc p<<1
#define rc p<<1|1
const int N=1e5+22;
const int INF=1e9;
#define mp(a,b) make_pair(a,b)
int a[N],b[N],le[N],ri[N],sum[N];
int xx[2*N];
int main()
{
    openfile();
    int n,m,i,j,x,y;
    while(cin>>n)
    {
        memset(le,0,sizeof(le));
        memset(ri,0,sizeof(ri));
        memset(sum,0,sizeof(sum));
        m=0;
        for(i=1;i<=n;++i)
        {
            scanf("%d%d",&x,&y);
            a[i]=x;
            b[i]=y;
            xx[m++]=a[i];
            xx[m++]=b[i];
        }
        sort(xx,xx+m);
        unique(xx,xx+m)-xx;
        for(i=1;i<=n;++i)
        {
            x=lower_bound(xx,xx+m,a[i])-xx;
            y=lower_bound(xx,xx+m,b[i])-xx;
            if(x-y)
                sum[x]++,sum[y]++;
            else
                sum[x]++;
            le[x]++;
            ri[y]++;
        }
        int ans=INF;
        for(i=0;i<m;++i)
            if(sum[i]>=(n+1)/2)
            {
                if(le[i]>=(n+1)/2)
                {
                    ans=0;
                    break;
                }
                else
                {
                    if(ri[i]<ans)
                        ans=ri[i];
                }
            }
        if(ans==INF) ans=-1;
        printf("%d\n", ans);
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<map>
#include<utility>
#include<cmath>
#include<sstream>
#include<fstream>
#include<bitset>
#include<numeric>
using namespace std;
#define hangdiana
#ifndef hangdian
  typedef long  long ll;
#endif
#ifdef hangdian
typedef __int64 ll;
#endif
#define pb(v) push_back(v)
#define FUCK cout<<"fuck"<<endl
void openfile()
{
#if 0
	freopen("input.txt","r", stdin);
	//freopen("output.txt","w",stdout);
#endif
}
#define NL puts("")
#define lc p<<1
#define rc p<<1|1
const int N=1e5+22;
const int INF=1e9;
#define mp(a,b) make_pair(a,b)
int a[N],b[N],le[N],ri[N],sum[N];
int xx[2*N];
int main()
{
	openfile();
	int n,m,i,j,x,y;
	while(cin>>n)
	{
		memset(le,0,sizeof(le));
		memset(ri,0,sizeof(ri));
		memset(sum,0,sizeof(sum));
		m=0;
		for(i=1;i<=n;++i)
		{
			scanf("%d%d",&x,&y);
			a[i]=x;
			b[i]=y;
			xx[m++]=a[i];
			xx[m++]=b[i];
		}
		sort(xx,xx+m);
		unique(xx,xx+m)-xx;
		for(i=1;i<=n;++i)
		{
			x=lower_bound(xx,xx+m,a[i])-xx;
			y=lower_bound(xx,xx+m,b[i])-xx;
			if(x-y)
				sum[x]++,sum[y]++;
			else
				sum[x]++;
			le[x]++;
			ri[y]++;
		}
		int ans=INF;
		for(i=0;i<m;++i)
			if(sum[i]>n/2)
			{
				if(le[i]>n/2)
				{
					ans=0;
					break;
				}
				else
				{
					if(ri[i]<ans)
						ans=ri[i];
				}
			}
		printf("%d\n", ans);
	}
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<map>
#include<utility>
#include<cmath>
#include<sstream>
#include<fstream>
#include<bitset>
#include<numeric>
using namespace std;
#define hangdiana
#ifndef hangdian
  typedef long  long ll;
#endif
#ifdef hangdian
typedef __int64 ll;
#endif
#define pb(v) push_back(v)
#define FUCK cout<<"fuck"<<endl
void openfile()
{
#if 0
    freopen("input.txt","r", stdin);
    //freopen("output.txt","w",stdout);
#endif
}
#define NL puts("")
#define lc p<<1
#define rc p<<1|1
const int N=1e5+22;
const int INF=1e9;
#define mp(a,b) make_pair(a,b)
int a[N],b[N],le[N],ri[N],sum[N];
int xx[2*N];
int main()
{
    openfile();
    int n,m,i,j,x,y;
    while(cin>>n)
    {
        memset(le,0,sizeof(le));
        memset(ri,0,sizeof(ri));
        memset(sum,0,sizeof(sum));
        m=0;
        for(i=1;i<=n;++i)
        {
            scanf("%d%d",&x,&y);
            a[i]=x;
            b[i]=y;
            xx[m++]=a[i];
            xx[m++]=b[i];
        }
        sort(xx,xx+m);
        unique(xx,xx+m)-xx;
        for(i=1;i<=n;++i)
        {
            x=lower_bound(xx,xx+m,a[i])-xx;
            y=lower_bound(xx,xx+m,b[i])-xx;
            if(x-y)
                sum[x]++,sum[y]++;
            else
                sum[x]++;
            le[x]++;
            ri[y]++;
        }
        int ans=INF;
        for(i=0;i<m;++i)
            if(sum[i]>=(n+1)/2)
            {
                if(le[i]>=(n+1)/2)
                {
                    ans=0;
                    break;
                }
                else
                {
                    if(le[i]+ri[i]>=(n+1)/2 && (n+1)/2-le[i]<ans)
                        ans=(n+1)/2-le[i];
                }
            }
        if(ans==INF) ans=-1;
        printf("%d\n", ans);
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<map>
#include<utility>
#include<cmath>
#include<sstream>
#include<fstream>
#include<bitset>
#include<numeric>
using namespace std;
#define hangdiana
#ifndef hangdian
  typedef long  long ll;
#endif
#ifdef hangdian
typedef __int64 ll;
#endif
#define pb(v) push_back(v)
#define FUCK cout<<"fuck"<<endl
void openfile()
{
#if 0
    freopen("input.txt","r", stdin);
    //freopen("output.txt","w",stdout);
#endif
}
#define NL puts("")
#define lc p<<1
#define rc p<<1|1
const int N=1e5+22;
const int INF=1e9;
#define mp(a,b) make_pair(a,b)
int a[N],b[N],le[N*2],ri[N*2],sum[N*2];
int xx[2*N];
int main()
{
    openfile();
    int n,m,i,j,x,y;
    while(cin>>n)
    {
        memset(le,0,sizeof(le));
        memset(ri,0,sizeof(ri));
        memset(sum,0,sizeof(sum));
        m=0;
        for(i=1;i<=n;++i)
        {
            scanf("%d%d",&x,&y);
            a[i]=x;
            b[i]=y;
            xx[m++]=a[i];
            xx[m++]=b[i];
        }
        sort(xx,xx+m);
        unique(xx,xx+m)-xx;
        for(i=1;i<=n;++i)
        {
            x=lower_bound(xx,xx+m,a[i])-xx;
            y=lower_bound(xx,xx+m,b[i])-xx;
            if(x-y)
                sum[x]++,sum[y]++;
            else
                sum[x]++;
            le[x]++;
            ri[y]++;
        }
        int ans=INF;
        for(i=0;i<m;++i)
            if(sum[i]>=(n+1)/2)
            {
                if(le[i]>=(n+1)/2)
                {
                    ans=0;
                    break;
                }
                else
                {
                    if((n+1)/2-le[i]<ans)
                        ans=(n+1)/2-le[i];
                }
            }
        if(ans==INF) ans=-1;
        printf("%d\n", ans);
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<map>
#include<utility>
#include<cmath>
#include<sstream>
#include<fstream>
#include<bitset>
#include<numeric>
using namespace std;
#define hangdiana
#ifndef hangdian
  typedef long  long ll;
#endif
#ifdef hangdian
typedef __int64 ll;
#endif
#define pb(v) push_back(v)
#define FUCK cout<<"fuck"<<endl
void openfile()
{
#if 0
    freopen("input.txt","r", stdin);
    //freopen("output.txt","w",stdout);
#endif
}
#define NL puts("")
#define lc p<<1
#define rc p<<1|1
const int N=1e5+22;
const int INF=1e9;
#define mp(a,b) make_pair(a,b)
int a[N],b[N],le[N],ri[N],sum[N];
int xx[2*N];
int main()
{
    openfile();
    int n,m,i,j,x,y;
    while(cin>>n)
    {
        memset(le,0,sizeof(le));
        memset(ri,0,sizeof(ri));
        memset(sum,0,sizeof(sum));
        m=0;
        for(i=1;i<=n;++i)
        {
            scanf("%d%d",&x,&y);
            a[i]=x;
            b[i]=y;
            xx[m++]=a[i];
            xx[m++]=b[i];
        }
        sort(xx,xx+m);
        unique(xx,xx+m)-xx;
        for(i=1;i<=n;++i)
        {
            x=lower_bound(xx,xx+m,a[i])-xx;
            y=lower_bound(xx,xx+m,b[i])-xx;
            if(x-y)
                sum[x]++,sum[y]++;
            else
                sum[x]++;
            le[x]++;
            ri[y]++;
        }
        int ans=INF;
        for(i=0;i<m;++i)
            if(sum[i]>n/2)
            {
                if(le[i]>n/2)
                {
                    ans=0;
                    break;
                }
                else
                {
                    if(ri[i]<ans)
                        ans=ri[i];
                }
            }
        if(ans==INF) ans=-1;
        printf("%d\n", ans);
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef set<int> si;
typedef set<string> ss;
typedef map<string,int>    msi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<string, vector <string> > mvss;
typedef map<char,int> mchi;
typedef map<int,char> mich;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<endl
#define prnt(a) cout<<a<<endl
#define mod 1000000009

// int setbit(int x, int pos)
// {
//     return x=x|(1<<pos);
// }

// int resetbit(int x, int pos)
// {
//     return x=x&~(1<<pos);
// }

// int checkbit(int x, int pos)
// {
//     return (bool)(x&(1<<pos));
// }

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

// int gcd(int a, int b)
// {
//     while(b)
//         b^=a^=b^=a%=b;
//     return a;
// }

// int inv_mod (int a, int b)
// {
// 	int b0=b, t, q;
// 	int x0=0, x1=1;
// 	if (b==1)	return 1;
// 	while(a>1)
// 	{
// 		q=a/b;
// 		t=b, b=a%b, a=t;
// 		t=x0, x0=x1-q*x0, x1=t;
// 	}
// 	if (x1<0)	x1+=b0;
// 	return x1;
// }

// Continuous Input
// char line[1000];
// while( gets( line ) )
// {
//     stringstream SS(line);
//     int num; vector<int> v;
//     while(SS >> num) v.push_back(num);
//         sort(v.begin(), v.end());
//
// }

mii front, back;

int main()
{
	int n, a, b;
	cin>>n;
	for (int i=0; i<n; i++)
	{
		cin>>a>>b;
		front[a]++;
		if (a!=b)
			back[b]++;
	}
	mii::iterator it;
	int ans=INF;
	for (it=front.begin(); it!=front.end(); it++)
	{
		int u=it->first;
		int v=it->second;
		if (v>=(n+1)/2)
		{
			ans=0;
			break;
		}
		else if (back[u]+v>=(n+1)/2)
		{
			ans=min(ans,(n+1)/2-v);
		}
	}
	if (ans==INF)
		prnt(-1);
	else
		prnt(ans);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef set<int> si;
typedef set<string> ss;
typedef map<string,int>    msi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<string, vector <string> > mvss;
typedef map<char,int> mchi;
typedef map<int,char> mich;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<endl
#define prnt(a) cout<<a<<endl
#define mod 1000000009

// int setbit(int x, int pos)
// {
//     return x=x|(1<<pos);
// }

// int resetbit(int x, int pos)
// {
//     return x=x&~(1<<pos);
// }

// int checkbit(int x, int pos)
// {
//     return (bool)(x&(1<<pos));
// }

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

// int gcd(int a, int b)
// {
//     while(b)
//         b^=a^=b^=a%=b;
//     return a;
// }

// int inv_mod (int a, int b)
// {
// 	int b0=b, t, q;
// 	int x0=0, x1=1;
// 	if (b==1)	return 1;
// 	while(a>1)
// 	{
// 		q=a/b;
// 		t=b, b=a%b, a=t;
// 		t=x0, x0=x1-q*x0, x1=t;
// 	}
// 	if (x1<0)	x1+=b0;
// 	return x1;
// }

// Continuous Input
// char line[1000];
// while( gets( line ) )
// {
//     stringstream SS(line);
//     int num; vector<int> v;
//     while(SS >> num) v.push_back(num);
//         sort(v.begin(), v.end());
//
// }

mii front, back;

int main()
{
	int n, a, b;
	cin>>n;
	for (int i=0; i<n; i++)
	{
		cin>>a>>b;
		front[a]++;
		if (a!=b)
			back[b]++;
	}
	mii::iterator it;
	int ans=INF;
	for (it=front.begin(); it!=front.end(); it++)
	{
		int u=it->first;
		int v=it->second;
		if (v>=(n+1)/2)
		{
			ans=0;
			break;
		}
		else if (back[u]+v>=(n+1)/2)
		{
			ans=min(ans,(n+1)/2-v);
		}
	}
	// prnt(ans);
	for (it=back.begin(); it!=back.end(); it++)
	{
		int u=it->first;
		int v=it->second;
		if (front[u]>=(n+1)/2)
		{
			ans=0;
			break;
		}
		else if (front[u]+v>=(n+1)/2)
		{
			ans=min(ans,v);
		}
	}
	if (ans==INF)
		prnt(-1);
	else
		prnt(ans);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef set<int> si;
typedef set<string> ss;
typedef map<string,int>    msi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<string, vector <string> > mvss;
typedef map<char,int> mchi;
typedef map<int,char> mich;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<endl
#define prnt(a) cout<<a<<endl
#define mod 1000000009

// int setbit(int x, int pos)
// {
//     return x=x|(1<<pos);
// }

// int resetbit(int x, int pos)
// {
//     return x=x&~(1<<pos);
// }

// int checkbit(int x, int pos)
// {
//     return (bool)(x&(1<<pos));
// }

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

// int gcd(int a, int b)
// {
//     while(b)
//         b^=a^=b^=a%=b;
//     return a;
// }

// int inv_mod (int a, int b)
// {
// 	int b0=b, t, q;
// 	int x0=0, x1=1;
// 	if (b==1)	return 1;
// 	while(a>1)
// 	{
// 		q=a/b;
// 		t=b, b=a%b, a=t;
// 		t=x0, x0=x1-q*x0, x1=t;
// 	}
// 	if (x1<0)	x1+=b0;
// 	return x1;
// }

// Continuous Input
// char line[1000];
// while( gets( line ) )
// {
//     stringstream SS(line);
//     int num; vector<int> v;
//     while(SS >> num) v.push_back(num);
//         sort(v.begin(), v.end());
//
// }

mii front, back;

int main()
{
	int n, a, b;
	cin>>n;
	for (int i=0; i<n; i++)
	{
		cin>>a>>b;
		front[a]++;
		back[b]++;
	}
	mii::iterator it;
	int ans=INF;
	for (it=front.begin(); it!=front.end(); it++)
	{
		int u=it->first;
		int v=it->second;
		if (back[u]>=(n+1)/2 || v>=(n+1)/2)
		{
			ans=0;
			break;
		}
		else if (back[u]+v>=(n+1)/2)
		{
			ans=min(ans,back[u]);
		}
	}
	if (ans==INF)
		prnt(-1);
	else
		prnt(ans);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef set<int> si;
typedef set<string> ss;
typedef map<string,int>    msi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<string, vector <string> > mvss;
typedef map<char,int> mchi;
typedef map<int,char> mich;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<endl
#define prnt(a) cout<<a<<endl
#define mod 1000000009

// int setbit(int x, int pos)
// {
//     return x=x|(1<<pos);
// }

// int resetbit(int x, int pos)
// {
//     return x=x&~(1<<pos);
// }

// int checkbit(int x, int pos)
// {
//     return (bool)(x&(1<<pos));
// }

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

// int gcd(int a, int b)
// {
//     while(b)
//         b^=a^=b^=a%=b;
//     return a;
// }

// int inv_mod (int a, int b)
// {
// 	int b0=b, t, q;
// 	int x0=0, x1=1;
// 	if (b==1)	return 1;
// 	while(a>1)
// 	{
// 		q=a/b;
// 		t=b, b=a%b, a=t;
// 		t=x0, x0=x1-q*x0, x1=t;
// 	}
// 	if (x1<0)	x1+=b0;
// 	return x1;
// }

// Continuous Input
// char line[1000];
// while( gets( line ) )
// {
//     stringstream SS(line);
//     int num; vector<int> v;
//     while(SS >> num) v.push_back(num);
//         sort(v.begin(), v.end());
//
// }

mii front, back;

int main()
{
	int n, a, b;
	cin>>n;
	for (int i=0; i<n; i++)
	{
		cin>>a>>b;
		front[a]++;
		if (a!=b)
			back[b]++;
	}
	mii::iterator it;
	int ans=INF;
	for (it=front.begin(); it!=front.end(); it++)
	{
		int u=it->first;
		int v=it->second;
		if (v>=(n+1)/2)
		{
			ans=0;
			break;
		}
		else if (back[u]+v>=(n+1)/2)
		{
			ans=min(ans,(n+1)/2-v);
		}
	}
	// prnt(ans);
	for (it=back.begin(); it!=back.end(); it++)
	{
		int u=it->first;
		int v=it->second;
		if (front[u]>=(n+1)/2)
		{
			ans=0;
			break;
		}
		else if (front[u]+v>=(n+1)/2)
		{
			ans=min(ans,(n+1)/2-front[u]);
		}
	}
	if (ans==INF)
		prnt(-1);
	else
		prnt(ans);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef set<int> si;
typedef set<string> ss;
typedef map<string,int>    msi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<string, vector <string> > mvss;
typedef map<char,int> mchi;
typedef map<int,char> mich;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<endl
#define prnt(a) cout<<a<<endl
#define mod 1000000009

// int setbit(int x, int pos)
// {
//     return x=x|(1<<pos);
// }

// int resetbit(int x, int pos)
// {
//     return x=x&~(1<<pos);
// }

// int checkbit(int x, int pos)
// {
//     return (bool)(x&(1<<pos));
// }

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

// int gcd(int a, int b)
// {
//     while(b)
//         b^=a^=b^=a%=b;
//     return a;
// }

// int inv_mod (int a, int b)
// {
// 	int b0=b, t, q;
// 	int x0=0, x1=1;
// 	if (b==1)	return 1;
// 	while(a>1)
// 	{
// 		q=a/b;
// 		t=b, b=a%b, a=t;
// 		t=x0, x0=x1-q*x0, x1=t;
// 	}
// 	if (x1<0)	x1+=b0;
// 	return x1;
// }

// Continuous Input
// char line[1000];
// while( gets( line ) )
// {
//     stringstream SS(line);
//     int num; vector<int> v;
//     while(SS >> num) v.push_back(num);
//         sort(v.begin(), v.end());
//
// }

mii front, back;

int main()
{
	int n, a, b;
	cin>>n;
	for (int i=0; i<n; i++)
	{
		cin>>a>>b;
		front[a]++;
		if (a!=b)
			back[b]++;
	}
	mii::iterator it;
	int ans=INF;
	for (it=front.begin(); it!=front.end(); it++)
	{
		int u=it->first;
		int v=it->second;
		if (v>=(n+1)/2)
		{
			ans=0;
			break;
		}
		else if (back[u]+v>=(n+1)/2)
		{
			ans=min(ans,back[u]);
		}
	}
	if (ans==INF)
		prnt(-1);
	else
		prnt(ans);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef set<int> si;
typedef set<string> ss;
typedef map<string,int>    msi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<string, vector <string> > mvss;
typedef map<char,int> mchi;
typedef map<int,char> mich;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<endl
#define prnt(a) cout<<a<<endl
#define mod 1000000009

// int setbit(int x, int pos)
// {
//     return x=x|(1<<pos);
// }

// int resetbit(int x, int pos)
// {
//     return x=x&~(1<<pos);
// }

// int checkbit(int x, int pos)
// {
//     return (bool)(x&(1<<pos));
// }

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

// int gcd(int a, int b)
// {
//     while(b)
//         b^=a^=b^=a%=b;
//     return a;
// }

// int inv_mod (int a, int b)
// {
// 	int b0=b, t, q;
// 	int x0=0, x1=1;
// 	if (b==1)	return 1;
// 	while(a>1)
// 	{
// 		q=a/b;
// 		t=b, b=a%b, a=t;
// 		t=x0, x0=x1-q*x0, x1=t;
// 	}
// 	if (x1<0)	x1+=b0;
// 	return x1;
// }

// Continuous Input
// char line[1000];
// while( gets( line ) )
// {
//     stringstream SS(line);
//     int num; vector<int> v;
//     while(SS >> num) v.push_back(num);
//         sort(v.begin(), v.end());
//
// }

mii front, back;

int main()
{
	int n, a, b;
	cin>>n;
	for (int i=0; i<n; i++)
	{
		cin>>a>>b;
		front[a]++;
		back[b]++;
	}
	mii::iterator it;
	int ans=INF;
	for (it=front.begin(); it!=front.end(); it++)
	{
		int u=it->first;
		int v=it->second;
		if (back[u]>=(n+1)/2 || v>=(n+1)/2)
		{
			ans=0;
			break;
		}
		else if (back[u]+v>=(n+1)/2)
		{
			ans=min(ans,back[u]);
		}
	}
	prnt(ans);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef set<int> si;
typedef set<string> ss;
typedef map<string,int>    msi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<string, vector <string> > mvss;
typedef map<char,int> mchi;
typedef map<int,char> mich;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<endl
#define prnt(a) cout<<a<<endl
#define mod 1000000009

// int setbit(int x, int pos)
// {
//     return x=x|(1<<pos);
// }

// int resetbit(int x, int pos)
// {
//     return x=x&~(1<<pos);
// }

// int checkbit(int x, int pos)
// {
//     return (bool)(x&(1<<pos));
// }

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

// int gcd(int a, int b)
// {
//     while(b)
//         b^=a^=b^=a%=b;
//     return a;
// }

// int inv_mod (int a, int b)
// {
// 	int b0=b, t, q;
// 	int x0=0, x1=1;
// 	if (b==1)	return 1;
// 	while(a>1)
// 	{
// 		q=a/b;
// 		t=b, b=a%b, a=t;
// 		t=x0, x0=x1-q*x0, x1=t;
// 	}
// 	if (x1<0)	x1+=b0;
// 	return x1;
// }

// Continuous Input
// char line[1000];
// while( gets( line ) )
// {
//     stringstream SS(line);
//     int num; vector<int> v;
//     while(SS >> num) v.push_back(num);
//         sort(v.begin(), v.end());
//
// }

mii front, back;

int main()
{
	int n, a, b;
	cin>>n;
	for (int i=0; i<n; i++)
	{
		cin>>a>>b;
		front[a]++;
		if (a!=b)
			back[b]++;
	}
	mii::iterator it;
	int ans=INF;
	for (it=front.begin(); it!=front.end(); it++)
	{
		int u=it->first;
		int v=it->second;
		if (back[u]>=(n+1)/2 || v>=(n+1)/2)
		{
			ans=0;
			break;
		}
		else if (back[u]+v>=(n+1)/2)
		{
			ans=min(ans,back[u]);
		}
	}
	if (ans==INF)
		prnt(-1);
	else
		prnt(ans);

    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <set>
#include <vector>
#include <map>
using namespace std;
int n,x,y,i,m,c,k;

map <pair <int,int>,int> a;
map <int,int> a1;
map <int,int> a2;
set <int> b;
int main(){
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        a1[x]++;
        if (x!=y) a2[y]++;
        b.insert(x);
        b.insert(y);
    }
    m=n+1;
    set <int> :: const_iterator i;
    for(i=b.begin();i!=b.end();i++)
    {
        if (a1[*i]+a2[*i]>=(n+1)/2) {
            x=(n+1)/2-a1[*i];
            if (x<m) m=x;
        }
    }
    cout<<m;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <set>
#include <vector>
#include <map>
using namespace std;
int n,x,y,i,m,c,k;

map <pair <int,int>,int> a;
map <int,int> a1;
map <int,int> a2;
set <int> b;
int main(){
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        a1[x]++;
        if (x!=y) a2[y]++;
        b.insert(x);
        b.insert(y);
    }
    m=n+1;
    set <int> :: const_iterator i;
    for(i=b.begin();i!=b.end();i++)
    {
        if (a1[*i]+a2[*i]>=(n+1)/2) {
            x=(n+1)/2-a1[*i];
            if (x<m) m=x;
        }
    }
    if (m<0) cout<<0; else cout<<m;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <set>
#include <vector>
#include <map>
using namespace std;
int n,x,y,i,m,c,k;
int b[10];
map <pair <int,int>,int> a;
int main(){
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        a[make_pair(x,y)]++;
        if (a[make_pair(x,y)]>m) {m=a[make_pair(x,y)];c=y;}
    }
    i=0;k=m;
    while(k<(n+1)/2)
    {
        if (a[make_pair(i,c)]>0) {k++;a[make_pair(i,c)]--;} else i++;
    }
    cout<<k-m;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <set>
#include <vector>
using namespace std;
int n,m,l,k,b[1000];
set a;
int main(){
    cin>>n>>m>>l;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        a.insert(x);
    }
    for(int i=0;i<m;i++)
    {
        cin>>b[i];
    }
    set <int> :: const_iterator x = a.lower_bound(b[i]);
    if(x == a.end()){
        x--;}
    else{
        int x1 = *x;
        if(x1==b[i]){k++;}
    else if(x!=a.begin(){
      x--;
      x1=*x;
     ....
    }
    else{
       x - ����� ������� �������
       ...
    }
}
    cout<<k;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <set>
#include <vector>
#include <map>
using namespace std;
int n,x,y,i,m,c,k;

map <pair <int,int>,int> a;
map <int,int> a1;
map <int,int> a2;
set <int> b;
int main(){
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        a1[x]++;
        if (x!=y) a2[y]++;
        b.insert(x);
        b.insert(y);
    }
    m=n+1;
    set <int> :: const_iterator i;
    for(i=b.begin();i!=b.end();i++)
    {
        if (a1[*i]+a2[*i]>=(n+1)/2) {
            x=(n+1)/2-a1[*i];
            if (x<m) m=x;
        }
    }
    if (m<0) cout<<0; else {
        if (m==n+1) cout<<-1; else cout<<m;
    }

    return 0;
}


#include<iostream>
#include<cstdio>
#define N 100001
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
long long x[N],y[N],q[N];
int main()
{
    int min,n,k,f=0,s,t,p=0;
    cin>>n;
    if (n%2==0) k=n/2; else k=n/2+1;
    FOR(i,1,n)
    cin>>x[i]>>y[i];
    min=10000000;
    FOR(i,1,n)
{
    FOR(k,1,f)
    if (q[k]==i) goto m1;
    s=1;
    FOR(j,i+1,n)
    if (x[i]==x[j]) {s++;q[++f]=j;}
    if (s>=k) {cout<<0;return 0;}
    t=0;
    FOR(j,1,n)
    if (x[i]==y[j]) t++;
    if (t+s>=k && min>t) {min=t;p=1;}
    m1:;
}
    if (p==0) cout<<-1;else  cout<<min;
    return 0;
}


# -*- coding: utf-8 -*-
"""
Created on Fri Sep  4 21:29:24 2020

@author: Dark Soul
"""

t=int(input(''))
arr=[]
for i in range(t):
    arr.append(list(map(int,input().split())))
for m in arr:
    n=m[0]
    x=m[1]
    y=m[2]

    diff=y-x
    for j in range(1,diff+1):
        if (y-x)%j==0 and (y-x)/j<n:
            diff=j
            break
    pos=y
    sol=[]
    while pos>0:
        sol.append(pos)
        pos-=diff
        if len(sol)==n:
            break
    pos=y+diff

    while len(sol)<n:
        sol.append(pos)
        pos+=diff

    print(*sol)


# -*- coding: utf-8 -*-
"""
Created on Fri Sep  4 21:29:24 2020

@author: Dark Soul
"""

t=int(input(''))
arr=[]
for i in range(t):
    arr.append(list(map(int,input().split())))
for m in arr:
    n=m[0]
    x=m[1]
    y=m[2]

    sol=1000000

    for i in range(51):
        for j in range(n):
            arr=[0]*n
            arr[j]=x
            flag=0
            for k in range(j+1,n):
                arr[k]+=(arr[k-1]+i)

                if arr[k]==y:
                    flag=1

            if flag==1:

                if sol>arr[k]:
                    fin=arr[k]
                    diff=fin-x
                    inc=(diff)/(n-1-j)
                    ini=fin-inc*(n-1)

                    if ini<=0:
                        continue
                    ans=arr.copy()
                    sol=arr[k]

    j=ans.index(x)
    fin=ans[n-1]
    diff=fin-x
    inc=int((diff)/(n-1-j))
    ini=(fin-inc*(n-1))
    for z in range(j):
            if ans[z]==0:

                ans[z]=ini+(z*inc)

    print(*ans)


# -*- coding: utf-8 -*-
"""
Created on Fri Sep  4 21:29:24 2020

@author: Dark Soul
"""

t=int(input(''))
arr=[]
for i in range(t):
    arr.append(list(map(int,input().split())))
for m in arr:
    n=m[0]
    x=m[1]
    y=m[2]

    sol=1000000

    for i in range(51):
        for j in range(n):
            arr=[0]*n
            arr[j]=x
            flag=0
            for k in range(j+1,n):
                arr[k]+=(arr[k-1]+i)

                if arr[k]==y:
                    flag=1

            if flag==1:

                if sol>arr[k]:
                    fin=arr[k]
                    diff=fin-x
                    inc=(diff)/(n-1-j)
                    ini=fin-inc*(n-1)

                    if ini<=0:
                        continue
                    ans=arr.copy()
                    solj=j

    j=ans.index(x)
    fin=ans[n-1]
    diff=fin-x
    inc=int((diff)/(n-1-j))
    ini=(fin-inc*(n-1))
    for z in range(j):
            if ans[z]==0:

                ans[z]=ini+(z*inc)

    print(*ans)


# -*- coding: utf-8 -*-
"""
Created on Fri Sep  4 21:29:24 2020

@author: Dark Soul
"""

t=int(input(''))
arr=[]
for i in range(t):
    arr.append(list(map(int,input().split())))
for m in arr:
    n=m[0]
    x=m[1]
    y=m[2]

    sol=55
    solj=0
    for i in range(1,51):
        for j in range(n):
            arr=[0]*n
            arr[j]=x
            flag=0
            for k in range(j+1,n):
                arr[k]+=(arr[k-1]+i)

                if arr[k]==y:
                    flag=1

            if flag==1:

                if sol>arr[k]:
                    fin=arr[k]
                    diff=fin-x
                    inc=(diff)/(n-1-j)
                    ini=fin-inc*(n-1)

                    if ini<=0:
                        continue
                    ans=arr.copy()
                    solj=j

    j=ans.index(x)
    fin=ans[n-1]
    diff=fin-x
    inc=int((diff)/(n-1-j))
    ini=(fin-inc*(n-1))
    for z in range(j):
            if ans[z]==0:

                ans[z]=ini+(z*inc)

    print(*ans)


def factors(a):
   l = []
   for i in range(1,a+1):
      if a%i==0: l.append(i)
   return l

for _ in range(int(input())):
   n, x, y = map(int, input().split())
   if n==2:
      print(x,y)
      continue
   diff = y-x
   ans = []

   f_list = factors(diff)
   for i in f_list:
      q = diff//i
      if q+1<=n: break

   diff = diff//q
   ans.append(y)
   while ans[0]-diff > x:
      ans.insert(0,ans[0]-diff)
   while x>0:
      ans.insert(0,x)
      x-=diff
   size = len(ans)
   while size<n:
      y+=diff
      ans.append(y)
      size = len(ans)

   size -=n
   print(*ans[size:])


def factors(a):
   l = []
   for i in range(1,(a//2)+1):
      if a%i==0: l.append(i)
   return l

def isPrime(a):
   if a<=3:
      if a!=2: return True
      return False
   for i in range(2,(a//2)+1):
      if a%i==0: return False
   return True

for _ in range(int(input())):
   n, x, y = map(int, input().split())
   if n==2:
      print(x,y)
      continue
   diff = y-x
   ans = []
   if isPrime(diff):
      ans.append(y)
      while x>0:
         ans.insert(0,x)
         x-=diff
      size = len(ans)
      while size<n:
         y+=diff
         ans.append(y)
         size = len(ans)
      size -=n
      print(*ans[size:])
      continue

   f_list = factors(diff)
   for i in f_list:
      q = diff//i
      if q+1<=n: break

   diff = diff//q
   ans.append(y)
   while ans[0]-diff > x:
      ans.insert(0,ans[0]-diff)
   while x>0:
      ans.insert(0,x)
      x-=diff
   size = len(ans)
   while size<n:
      y+=diff
      ans.append(y)
      size = len(ans)

   size -=n
   print(*ans[size:])


def factors(a):
   l = []
   for i in range(1,a//2):
      if a%i==0: l.append(i)
   return l

def isPrime(a):
   if a<=3: return True
   for i in range(2,(a//2)+1):
      if a%i==0: return False
   return True

for _ in range(int(input())):
   n, x, y = map(int, input().split())
   if n==2:
      print(x,y)
      continue
   diff = y-x
   ans = []
   if isPrime(diff):
      ans.append(y)
      while x>0:
         ans.insert(0,x)
         x-=diff
      size = len(ans)
      while size<n:
         y+=diff
         ans.append(y)
         size = len(ans)
      print(*ans)
      continue

   f_list = factors(diff)
   for i in f_list:
      q = diff//i
      if q+1<=n: break

   diff = diff//q
   ans.append(y)
   while ans[0]-diff > x:
      ans.insert(0,ans[0]-diff)
   while x>0:
      ans.insert(0,x)
      x-=diff
   size = len(ans)
   while size<n:
      y+=diff
      ans.append(y)
      size = len(ans)

   if size==n: print(*ans)
   else:
      size -=n
      print(*ans[size:])


def factors(a):
   l = []
   for i in range(1,(a//2)+1):
      if a%i==0: l.append(i)
   return l

def isPrime(a):
   if a<=3:
      if a!=2: return True
      return False
   for i in range(2,(a//2)+1):
      if a%i==0: return False
   return True

for _ in range(int(input())):
   n, x, y = map(int, input().split())
   if n==2:
      print(x,y)
      continue
   diff = y-x
   ans = []
   if isPrime(diff):
      ans.append(y)
      while x>0:
         ans.insert(0,x)
         x-=diff
      size = len(ans)
      while size<n:
         y+=diff
         ans.append(y)
         size = len(ans)
      print(*ans)
      continue

   f_list = factors(diff)
   for i in f_list:
      q = diff//i
      if q+1<=n: break

   diff = diff//q
   ans.append(y)
   while ans[0]-diff > x:
      ans.insert(0,ans[0]-diff)
   while x>0:
      ans.insert(0,x)
      x-=diff
   size = len(ans)
   while size<n:
      y+=diff
      ans.append(y)
      size = len(ans)

   if size==n: print(*ans)
   else:
      size -=n
      print(*ans[size:])


# https://codeforces.com/contest/1409/problem/C

t= int(input())
for i in range(t):
    n, x, y = map(int, input().split())

    xy_diff = n - 1
    while xy_diff > 0:
        if (y-x) % xy_diff == 0:
            d = (y-x) // xy_diff
            break
        else:
            xy_diff -= 1
    ans = list()
    temp = y
    while n > 0 and temp >= 1:
        ans.append(temp)
        n -= 1
        temp -=  d
    temp = y
    while n > 0:
        ans.append(temp)
        temp += d
        n -= 1
    print(*ans)


# https://codeforces.com/contest/1409/problem/C

t= int(input())
for i in range(t):
    n, x, y = map(int, input().split())

    xy_diff = n - 1
    while xy_diff > 0:
        if (y-x) % xy_diff == 0:
            d = (y-x) // xy_diff
            break
        else:
            xy_diff -= 1
    ans = list()
    temp = y
    while n > 0 and temp >= 1:
        ans.append(temp)
        n -= 1
        temp -=  d
    temp = y + d
    while n > 0:
        ans.append(temp)
        temp += d
        n -= 1
    print(*ans)


t=int(input())
while t>0:
    t-=1
    n,x,y=[int(x) for x in input().split()]
    k=[x for x in range(1,n)]
    for i in reversed(k):
        if (y-x)%i==0:
            cd=(y-x)//i
            break
    arr=[]
    ans=y
    ans1=y
    while ans>0 and len(arr)<n:
        arr.append(ans)
        ans-=cd
    while len(arr)<n:
        ans1+=cd
        arr.append(ans1)
    arr.sort()
    print(*arr)


t=int(input())
while t>0:
    t-=1
    n,x,y=[int(x) for x in input().split()]
    k=[x for x in range(1,n)]
    for i in reversed(k):
        if (y-x)%i==0:
            cd=(y-x)//i
            break
    arr=[]
    ans=y
    ans1=y
    while ans>0:
        arr.append(ans)
        ans-=cd
    while len(arr)<n:
        ans1+=cd
        arr.append(ans1)
    arr.sort()
    print(*arr)


n=int(input())
while n>0:
    l,a,b=[int(x) for x in input().split()]
    for s in range(1,a+1):
        for d in range(1,b-a+1):
            x=[]
            for i in range(l):
                x.append(s+i*d)
            if a in x and b in x:
                for item in x:
                    print(item,end=" ")
                print("")
                break
        if a in x and b in x:
            break
    n-=1


def divisors(a, b):
    result = []
    x = b - a
    for i in range(1, x + 1):
        if x % i == 0:
            result.append(i)
    return result

def solution():
    x = int(input())
    for _ in range(x):
        n, x, y = input().split()
        my_divisors = divisors(int(x), int(y))
        gap = int(y) - int(x)
        current_max = 1
        if int(y) + int(x) - 1 == int(n):
            current_max = 1
        else:
            for i in range(len(my_divisors)):
                if my_divisors[i] * (int(n) - 2) > gap and not current_max == 1:
                    break
                current_max = my_divisors[i]
        count = int(n) - 1
        current = int(x)
        print(str(current), end="")
        current += current_max
        while current < int(y) and count > 1:
            print(" " + str(current), end="")
            current += current_max
            count -= 1
        print(" " + str(int(y)), end="")
        count -= 1
        current = int(x) - current_max
        while current >= 1 and count > 0 :
            print(" " + str(current), end="")
            current -= current_max
            count -= 1
        current = int(y) + current_max
        while count > 0 :
            print(" " + str(current), end="")
            current += current_max
            count -= 1
        print()
solution()


def divisors(a, b):
    result = []
    x = b - a
    for i in range(1, x + 1):
        if x % i == 0:
            result.append(i)
    return result

def solution():
    x = int(input())
    for _ in range(x):
        n, x, y = input().split()
        my_divisors = divisors(int(x), int(y))
        gap = int(y) - int(x)
        current_max = 1
        if int(y) + int(x) - 1 == int(n):
            current_max = 1
        else:
            for i in range(len(my_divisors)):
                if my_divisors[i] * (int(n) - 2) >= gap and not current_max == 1:
                    break
                current_max = my_divisors[i]
        count = int(n) - 1
        current = int(x)
        print(str(current), end="")
        current += current_max
        while current < int(y) and count > 1:
            print(" " + str(current), end="")
            current += current_max
            count -= 1
        print(" " + str(int(y)), end="")
        count -= 1
        current = int(x) - current_max
        while current >= 1 and count > 0 :
            print(" " + str(current), end="")
            current -= current_max
            count -= 1
        current = int(y) + current_max
        while count > 0 :
            print(" " + str(current), end="")
            current += current_max
            count -= 1
        print()
solution()


def divisors(a, b):
    result = []
    x = b - a
    for i in range(1, x + 1):
        if x % i == 0:
            result.append(i)
    return result

def solution():
    x = int(input())
    for _ in range(x):
        n, x, y = input().split()
        my_divisors = divisors(int(x), int(y))
        gap = int(y) - int(x)
        current_max = int(y) - int(x)
        if int(y) - int(x) - 1 == int(n) - 2:
            current_max = 1
        else:
            for i in range(len(my_divisors)):
                if (my_divisors[i] * int(n) - 2) >= gap >= gap - my_divisors[i]:
                    current_max = my_divisors[i]
                    break
        count = int(n) - 1
        current = int(x)
        print(str(current), end="")
        current += current_max
        while current < int(y) and count > 1:
            print(" " + str(current), end="")
            current += current_max
            count -= 1
        print(" " + str(int(y)), end="")
        count -= 1
        current = int(x) - current_max
        while current >= 1 and count > 0 :
            print(" " + str(current), end="")
            current -= current_max
            count -= 1
        current = int(y) + current_max
        while count > 0 :
            print(" " + str(current), end="")
            current += current_max
            count -= 1
        print()
solution()


def divisors(a, b):
    result = []
    x = b - a
    for i in range(1, x + 1):
        if x % i == 0:
            result.append(i)
    return result

def solution():
    x = int(input())
    for _ in range(x):
        n, x, y = input().split()
        my_divisors = divisors(int(x), int(y))
        gap = int(y) - int(x)
        current_max = int(y) - int(x)
        if int(y) + int(x) - 1 == int(n):
            current_max = 1
        else:
            for i in range(len(my_divisors)):
                if (my_divisors[i] * int(n) - 2) >= gap >= gap - my_divisors[i]:
                    current_max = my_divisors[i]
                    break
        count = int(n) - 1
        current = int(x)
        print(str(current), end="")
        current += current_max
        while current < int(y) and count > 1:
            print(" " + str(current), end="")
            current += current_max
            count -= 1
        print(" " + str(int(y)), end="")
        count -= 1
        current = int(x) - current_max
        while current >= 1 and count > 0 :
            print(" " + str(current), end="")
            current -= current_max
            count -= 1
        current = int(y) + current_max
        while count > 0 :
            print(" " + str(current), end="")
            current += current_max
            count -= 1
        print()
solution()


def divisors(a, b):
    result = []
    x = b - a
    for i in range(2, x + 1):
        if x % i == 0:
            result.append(i)
    return result

def solution():
    x = int(input())
    for _ in range(x):
        n, x, y = input().split()
        my_divisors = divisors(int(x), int(y))
        gap = int(y) - int(x)
        current_max = 1
        if not my_divisors:
            current_max = int(y) - int(x)
        else:
            for i in range(len(my_divisors)):
                if my_divisors[i] * (int(n) - 2) > gap and not current_max == 1:
                    break
                current_max = my_divisors[i]
        count = int(n) - 1
        current = int(x)
        print(str(current), end="")
        current += current_max
        while current < int(y) and count > 1:
            print(" " + str(current), end="")
            current += current_max
            count -= 1
        print(" " + str(int(y)), end="")
        count -= 1
        current = int(x) - current_max
        while current >= 1 and count > 0 :
            print(" " + str(current), end="")
            current -= current_max
            count -= 1
        current = int(y) + current_max
        while count > 0 :
            print(" " + str(current), end="")
            current += current_max
            count -= 1
        print()
solution()