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

public class Main
{
	static 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 String readString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

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

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

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

static class OutputWriter {
		private final PrintWriter writer;

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

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

		public void print(Object...objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0)
					writer.print(' ');
				writer.print(objects[i]);
			}
		}

		public void printLine(Object...objects) {
			print(objects);
			writer.println();
		}

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

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

		}

    static class IOUtils {

		public static int[] readIntArray(InputReader in, int size) {
			int[] array = new int[size];
			for (int i = 0; i < size; i++)
				array[i] = in.readInt();
			return array;
		}
    }
    static int[] a = new int[200005];
    static int[] s = new int[200005];
    static OutputWriter out;
    static InputReader in;
    public static void main (String[] args) throws java.lang.Exception
	{
	    out = new OutputWriter(System.out);
		in = new InputReader(System.in);
        int x = in.readInt();
        int y = in.readInt();
        x = in.readInt()-x; y = in.readInt()-y;
        int a = in.readInt(); int b = in.readInt();
        if(x%a==0 && y%b==0)if((x/a+y/b)%2==0)out.print("YES");
        else out.print("NO");
        out.flush();
        out.close();
	}

	public static void add(int index, int value, int[] b){
	    while(index < b.length){
	        b[index] += value;
	        index = index + (index & (-index));
	    }
	}

	public static int getSum(int index, int [] b){
	    int sum = 0;
	    while(index > 0){
	        sum += b[index];
	        index = index - (index&(-index));
	    }
	    return sum;
	}

	public static void printArray(int[] a){
	    for(int i=1; i<a.length; i++)out.print(a[i]+" ");
	    out.printLine("---------");
	}

	static class Pair implements Comparable<Pair>{
	    int s;
	    //int d;
	    int len;
	    public Pair(int a, int c){
	        s = a; len = c;
	    }
	    public int compareTo(Pair p){
	        if(this.len > p.len)return 1;
	        else if(this.len < p.len)return -1;
	        return 0;
	    }
	}
}


import java.util.Scanner;

public class MinimumTriangulation {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long dp[] = new long[n];
		dp[1] = 1;
		dp[2] = 2;
		dp[3] = 6;
		if(n > 3) {
			for(int i = 4; i < n; i++) {
				dp[i] = dp[i-1]*(i-1)*i;
			}
		}
		System.out.print(dp[n-1]);
 	}

}


import java.util.Scanner;

public class DZY_LOVES_SUBSEQ {

	public static void main(String[] args) {

		Scanner nik = new Scanner(System.in);
		int n = nik.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nik.nextInt();
		}
		int k = 1;
		int l = 0;
		int max = 1;
		for (int i = 0; i < n; i++) {

			if (i + 1 < n && a[i + 1] < a[i] && k == 0) {

				while (l < n && a[l + 1] < a[l]) {
					l++;
				}

			} else if (i + 1 < n && a[i + 1] < a[i] && k == 1) {
				k--;
			}
			max = max > (i - l + 1) ? max : (i - l + 1);
		}
		System.out.println(max);
	}

}

/*
 *
 * 8 2 4 5 1 7 8 9 10
 *
 */


public class T1140D {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int result = 0;
        for (int i = 2; i < n; ++i) {
            result += i * (i + 1);
        }
        System.out.println(result);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Solution {

//		public static final double eps = 1e-9;
//		public static final int mod = 1000000007;
//		public static final double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
//		public static final int sievesize = (int) (1e7 + 10);
//		public static boolean[] prime;
//		public static final int dx[] = {1, -1, 0, 0};
//		public static final int dy[] = {0, 0, 1, -1};

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

	static class Task {

		public void solve(int testNumber, InputReader in, OutputWriter out) throws IOException {
			String str = in.next();
			StringBuilder res = new StringBuilder();
			int i = 0, j = 0;
			if (str.substring(0, 3).equals("dot")) {
				res.append("dot");
				i = 3;
			}
			else if (str.substring(0, 2).equals("at")) {
				res.append("at");
				i = 2;
			}
			if (str.substring(str.length() - 3).equals("dot")) {
				j = str.length() - 3;
			}
			else if (str.substring(str.length() - 2).equals("at")) {
				j = str.length() - 2;
			}
			else {
				j = str.length();
			}
			boolean flag = false;
			while (i < j) {
				if (i + 3 < str.length() && str.substring(i, i + 3).equals("dot")) {
					res.append(".");
					i += 3;
				}
				else if (i + 2 < str.length() && str.substring(i, i + 2).equals("at")) {
					if (!flag) {
						res.append("@");
						i += 2;
						flag = true;
					}
				}
				else {
					res.append(str.charAt(i));
					i++;
				}
			}
			res.append(str.substring(j));
			out.println(res);
		}

//		static class Node {
//			String name;
//			LinkedList<Node> list;
//
//			public Node(String name) {
//				this.name = name;
//				list = new LinkedList<>();
//			}
//		}
//
//		static class Pair {
//	      	int first, second;
//
//		    public Pair(int first, int second) {
//	    		this.first = first;
//				this.second = second;
//			}
//	    }
	}

	//	public static int[] shuffle(int arr[], Random gen) {
	//		for(int i = 0, n = arr.length; i < n; i++)
	//		{
	//			int index = gen.nextInt(n - i) + i;
	//			int temp = arr[i];
	//			arr[i] = arr[index];
	//			arr[index] = temp;
	//		}
	//		return arr;
	//	}
	//
	//	public static boolean triangle(long a, long b, long c){
	//	    return ((a+b) > c && (b+c) >a && (a+c) > b);
	//	}
	//
	//	public static boolean isPerfectSquare(long n){
	//		if (n < 0)
	//	    	return false;
	//	    long test = (long) (Math.sqrt(n) + 0.5);
	//	    return test*test == n;
	//	}
	//
	//	public static int isnum(char s){
	//		if(s=='1' || s=='2' || s=='3' || s=='4' || s=='5' || s=='6' || s=='7' || s=='8' || s=='9' || s=='0')
	//	    	return 1;
	//		return 0;
	//	}
	//
	//	public static long nextPowerOf2(long n){
	//	    n--;
	//	    n |= n >> 1;
	//	    n |= n >> 2;
	//	    n |= n >> 4;
	//	    n |= n >> 8;
	//	    n |= n >> 16;
	//	    n++;
	//	    return n;
	//	}
	//
//		public static int gcd(int a, int b){
//		    int t;
//		    while (b > 0){
//		    	a = a % b;
//		    	t = a;
//		    	a = b;
//		    	b = t;
//	    	}
//		    return a;
//		}
	//
	//	public static void sieve(int n){
	//		prime=new boolean[sievesize+1];
	//		Arrays.fill(prime, true);
	//	    long x, y;
	//	    for(x = 2; x * x <= sievesize; x++)
	//	    {
	//	    	if(prime[(int) x])
	//	    		for(y = x * 2; y <= sievesize; y += x)
	//	    			prime[(int) y]=false;
	//	    }
	//	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

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

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

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

		public char nextChar() {
			return next().charAt(0);
		}

		public float nextFloat() {
			return Float.parseFloat(next());
		}

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

		public int[] nextIntArray(int size) {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			int[] arr=new int[size];
			for(int i = 0; i < size; i++)
				arr[i] = Integer.parseInt(tokenizer.nextToken());
			return arr;
		}

		public long[] nextLongArray(int size) {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			long[] arr=new long[size];
			for(int i = 0; i < size; i++)
				arr[i] = Long.parseLong(tokenizer.nextToken());
			return arr;
		}

		public double[] nextDoubleArray(int size) {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			double[] arr=new double[size];
			for(int i = 0; i < size; i++)
				arr[i] = Double.parseDouble(tokenizer.nextToken());
			return arr;
		}

		public String[] nextStringArray(int size) throws IOException {
			String[] arr=new String[size];
			for(int i = 0; i < size; i++)
				arr[i] = reader.readLine();
			return arr;
		}

		public char[] nextCharArray(int size) throws IOException {
			char[] arr=reader.readLine().toCharArray();
			return arr;
		}
	}

	static class OutputWriter {
		public PrintWriter pw;

		public OutputWriter(OutputStream stream) {
			pw = new PrintWriter(stream);
		}

		public void println() {
			pw.println();
		}

		public void println(Object str) {
			pw.println(str);
		}

		public void print(Object str) {
			pw.print(str + " ");
		}

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

		public void flush() {
			pw.flush();
		}

		public void printStringArray(String[] arr) {
			for(int i = 0; i < arr.length; i++)
				pw.println(arr[i]);
		}

		public void printIntArray(int[] arr) {
			for(int i = 0; i < arr.length; i++)
				pw.print(arr[i] + " ");
		}

		public void printLongArray(long[] arr) {
			for(int i = 0; i < arr.length; i++)
				pw.print(arr[i] + " ");
		}

		public void printCharArray(char[] arr) {
			for(int i = 0; i < arr.length; i++)
				pw.print(arr[i] + " ");
		}

		public void printFloatArray(float[] arr) {
			for(int i = 0; i < arr.length; i++)
				pw.print(arr[i] + " ");
		}

		public void printDoubleArray(double[] arr) {
			for(int i = 0; i < arr.length; i++)
				pw.print(arr[i] + " ");
		}
	}
}


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

public class Main {

    public static void main(String args[]) throws IOException {
        Reader.init(System.in);
   String ar = Reader.next();
   ar = ar.replace("dot", ".");
   int x = ar.substring(1, ar.length()-1).indexOf("at");

   String tem = ar;
   ar = ar.substring(0, x);
   ar+="@";
   ar+=tem.substring(x+2, tem.length());
       if(ar.charAt(0)=='.')
         ar=  ar.replaceFirst(".", "dot");
       if(ar.charAt(ar.length()-1)=='.'){
       StringBuilder b = new StringBuilder(ar);
       b.replace(ar.lastIndexOf("."),ar.lastIndexOf(".")+1, "dot");
       ar = b.toString();
               }

        System.out.println(ar);

    }

    private static boolean isSorted(int[] ar) {
        for (int i = 0; i < ar.length - 1; i++) {
            if (ar[i + 1] - ar[i] != 1) {
                return false;
            }
        }
        return true;
    }
}

class suger implements Comparable<suger> {

    double d;
    double c;

    public suger(double d, double c) {
        this.d = d;
        this.c = c;
    }

    @Override
    public int compareTo(suger o) {
        return Double.compare(this.c, o.c);
    }

}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /**
     * call this method to initialize reader for InputStream
     */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    /**
     * get next word
     */
    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
//            TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

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

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

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

    static public void nextIntArrays(int[]... arrays) throws IOException {
        for (int i = 1; i < arrays.length; ++i) {
            if (arrays[i].length != arrays[0].length) {
                throw new InputMismatchException("Lengths are different");
            }
        }
        for (int i = 0; i < arrays[0].length; ++i) {
            for (int[] array : arrays) {
                array[i] = nextInt();
            }
        }
    }

    static public void nextLineArrays(String[]... arrays) throws IOException {
        for (int i = 1; i < arrays.length; ++i) {
            if (arrays[i].length != arrays[0].length) {
                throw new InputMismatchException("Lengths are different");
            }
        }
        for (int i = 0; i < arrays[0].length; ++i) {
            for (String[] array : arrays) {
                array[i] = reader.readLine();
            }
        }
    }
}


//package round673;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class D {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni(), m = ni(), Q = ni();
		int[] a = na(n);
		int[] from = new int[m];
		int[] to = new int[m];
		boolean[] remain = new boolean[m];
		for(int i = 0;i < m;i++) {
			from[i] = ni()-1;
			to[i] = ni()-1;
		}
		Arrays.fill(remain, true);

		int[][] qs = new int[Q][];
		for(int i = 0;i < Q;i++) {
			qs[i] = new int[] {ni(), ni()-1};
			if(qs[i][0] == 2) {
				remain[qs[i][1]] = false;
			}
		}

		int gen = n;
		int[] par = new int[2*n];
		Arrays.fill(par, -1);
		DJSet ds = new DJSet(n);
		for(int i = 0;i < m;i++) {
			if(remain[i]) {
				if(!ds.equiv(from[i], to[i])) {
					int f = ds.tr[ds.root(from[i])];
					int t = ds.tr[ds.root(to[i])];
					ds.union(from[i], to[i]);
					par[f] = gen;
					par[t] = gen;
					ds.tr[ds.root(from[i])] = gen;
					gen++;
				}
			}
		}

		int[] time = new int[2*n];
		Arrays.fill(time, Q);
		for(int i = Q-1;i >= 0;i--) {
			if(qs[i][0] == 2) {
				int ind = qs[i][1];
				if(!ds.equiv(from[ind], to[ind])) {
					int f = ds.tr[ds.root(from[ind])];
					int t = ds.tr[ds.root(to[ind])];
					ds.union(from[ind], to[ind]);
					par[f] = gen;
					par[t] = gen;
					ds.tr[ds.root(from[ind])] = gen;
					time[gen] = i;
					gen++;
				}
			}
		}

		time[2*n-1] = -1;
		for(int i = n;i < 2*n-1;i++) {
			if(par[i] == -1) {
				par[i] = 2*n-1;
			}
		}

		int[][] g = parentToG(par);
		int[][] rights = makeRights(g, par, 2*n-1);
		int[] iord = rights[1], right = rights[2];
		int[][] spar = logstepParents(par);

		int[] b = new int[2*n];
		for(int i = 0;i < n;i++) {
			b[iord[i]] = -a[i];
		}
		SegmentTreeRMQPos st = new SegmentTreeRMQPos(b);
		for(int i = 0;i < Q;i++) {
			int[] q = qs[i];
			if(q[0] == 1) {
				int v = q[1];
				for(int d = spar.length-1;d >= 0;d--) {
					int anc = spar[d][v];
					if(anc == -1)continue;
					if(time[anc] < i)continue;
					v = anc;
				}
				int[] vp = st.min(iord[v], right[iord[v]]+1);
				out.println(-vp[0]);
				st.update(vp[1], 0);
			}
		}
	}

	public static class SegmentTreeRMQPos {
		public int M, H, N, B;
		public int[] st;
		public int[] pos;

		public SegmentTreeRMQPos(int n)
		{
			N = n;
			M = Integer.highestOneBit(Math.max(n, 1))<<2;
			H = M>>>1;
			B = Integer.numberOfTrailingZeros(H);
			st = new int[M];
			pos = new int[M];
			for(int i = M-1;i >= H;i--)pos[i] = i-H;
			for(int i = H-1;i >= 0;i--){
				pos[i] = pos[2*i];
			}
		}

		public SegmentTreeRMQPos(int[] a)
		{
			N = a.length;
			M = Integer.highestOneBit(Math.max(N, 1))<<2;
			H = M>>>1;
			B = Integer.numberOfTrailingZeros(H);
			st = new int[M];
			pos = new int[M];
			for(int i = 0;i < N;i++){
				st[H+i] = a[i];
				pos[H+i] = i;
			}
			Arrays.fill(st, H+N, M, Integer.MAX_VALUE);
			for(int i = (M>>1)-1;i >= 1;i--)propagate(i);
		}

		public void update(int p, int x)
		{
			st[H+p] = x;
			for(int i = (H+p)>>>1;i >= 1;i >>>= 1)propagate(i);
		}

		private void propagate(int i)
		{
			if(st[i*2] <= st[i*2+1]){
				st[i] = st[i*2];
				pos[i] = pos[i*2];
			}else{
				st[i] = st[i*2+1];
				pos[i] = pos[i*2+1];
			}
		}

		public int[] min(int f, int t) { return min(f, t, B); }

		public int[] min(int f, int t, int b)
		{
			if(f>>b<<b==f && t+1>>b<<b==t+1){
				return new int[]{st[(H|f)>>b], pos[(H|f)>>b]};
			}

			b--;
			if((f^t)<<31-b<0){
				int w = t>>b<<b;
				int[] l = min(f, w-1, b);
				int[] r = min(w, t, b);
				return l[0] <= r[0] ? l : r;
			}else{
				return min(f, t, b);
			}
		}
	}

	public static int[] sortByPreorder(int[][] g, int root){
		int n = g.length;
		int[] stack = new int[n];
		int[] ord = new int[n];
		boolean[] ved = new boolean[n];
		stack[0] = root;
		int p = 1;
		int r = 0;
		ved[root] = true;
		while(p > 0){
			int cur = stack[p-1];
			ord[r++] = cur;
			p--;
			for(int e : g[cur]){
				if(!ved[e]){
					ved[e] = true;
					stack[p++] = e;
				}
			}
		}
		return ord;
	}

	public static int[][] makeRights(int[][] g, int[] par, int root)
	{
		int n = g.length;
		int[] ord = sortByPreorder(g, root);
		int[] iord = new int[n];
		for(int i = 0;i < n;i++)iord[ord[i]] = i;

		int[] right = new int[n];
		for(int i = n-1;i >= 1;i--){
			if(right[i] == 0)right[i] = i;
			int p = iord[par[ord[i]]];
			right[p] = Math.max(right[p], right[i]);
		}
		return new int[][]{ord, iord, right};
	}

	public static int lca2(int a, int b, int[][] spar, int[] depth) {
		if (depth[a] < depth[b]) {
			b = ancestor(b, depth[b] - depth[a], spar);
		} else if (depth[a] > depth[b]) {
			a = ancestor(a, depth[a] - depth[b], spar);
		}

		if (a == b)
			return a;
		int sa = a, sb = b;
		for (int low = 0, high = depth[a], t = Integer.highestOneBit(high), k = Integer
				.numberOfTrailingZeros(t); t > 0; t >>>= 1, k--) {
			if ((low ^ high) >= t) {
				if (spar[k][sa] != spar[k][sb]) {
					low |= t;
					sa = spar[k][sa];
					sb = spar[k][sb];
				} else {
					high = low | t - 1;
				}
			}
		}
		return spar[0][sa];
	}

	protected static int ancestor(int a, int m, int[][] spar) {
		for (int i = 0; m > 0 && a != -1; m >>>= 1, i++) {
			if ((m & 1) == 1)
				a = spar[i][a];
		}
		return a;
	}

	public static int[][] logstepParents(int[] par) {
		int n = par.length;
		int m = Integer.numberOfTrailingZeros(Integer.highestOneBit(n - 1)) + 1;
		int[][] pars = new int[m][n];
		pars[0] = par;
		for (int j = 1; j < m; j++) {
			for (int i = 0; i < n; i++) {
				pars[j][i] = pars[j - 1][i] == -1 ? -1 : pars[j - 1][pars[j - 1][i]];
			}
		}
		return pars;
	}

	public static int[][] parentToG(int[] par)
	{
		int n = par.length;
		int[] ct = new int[n];
		for(int i = 0;i < n;i++){
			if(par[i] >= 0){
				ct[i]++;
				ct[par[i]]++;
			}
		}
		int[][] g = new int[n][];
		for(int i = 0;i < n;i++){
			g[i] = new int[ct[i]];
		}
		for(int i = 0;i < n;i++){
			if(par[i] >= 0){
				g[par[i]][--ct[par[i]]] = i;
				g[i][--ct[i]] = par[i];
			}
		}
		return g;
	}

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

		public DJSet(int n) {
			upper = new int[n];
			Arrays.fill(upper, -1);
			tr = new int[n];
			for(int i = 0;i < n;i++) tr[i] = i;
		}

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

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

		public boolean union(int x, int y) {
			x = root(x);
			y = root(y);
			if (x != y) {
				if (upper[y] < upper[x]) {
					int d = x;
					x = y;
					y = d;
				}
				upper[x] += upper[y];
				upper[y] = x;
			}
			return x == y;
		}

		public int count() {
			int ct = 0;
			for (int u : upper)
				if (u < 0)
					ct++;
			return ct;
		}
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new D().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


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

public class E {
	FastScanner in;
	PrintWriter out;
	boolean systemIO = true;

	public class DSU {
		int[] sz;
		int[] p;

		public DSU(int n) {
			sz = new int[n];
			p = new int[n];
			for (int i = 0; i < p.length; i++) {
				p[i] = i;
				sz[i] = 1;
			}
		}

		public int get(int x) {
			if (x == p[x]) {
				return x;
			}
			int par = get(p[x]);
			p[x] = par;
			return par;
		}

		public boolean unite(int a, int b) {
			int pa = get(a);
			int pb = get(b);
			if (pa == pb) {
				return false;
			}
			if (sz[pa] < sz[pb]) {
				p[pa] = pb;
				sz[pb] += sz[pa];
			} else {
				p[pb] = pa;
				sz[pa] += sz[pb];
			}
			return true;
		}
	}

	public class SegmentTreeAdd {
		int pow;
		long[] max;
		long[] delta;
		boolean[] flag;

		public SegmentTreeAdd(long[] a) {
			pow = 1;
			while (pow < a.length) {
				pow *= 2;
			}
			flag = new boolean[2 * pow];
			max = new long[2 * pow];
			delta = new long[2 * pow];
			for (int i = 0; i < max.length; i++) {
				max[i] = Long.MIN_VALUE / 2;
			}
			for (int i = 0; i < a.length; i++) {
				max[pow + i] = a[i];
			}
			for (int i = pow - 1; i > 0; i--) {
				max[i] = f(max[2 * i], max[2 * i + 1]);
			}
		}

		public long get(int v, int tl, int tr, int l, int r) {
			push(v, tl, tr);
			if (l > r) {
				return Long.MIN_VALUE / 2;
			}
			if (l == tl && r == tr) {
				return max[v];
			}
			int tm = (tl + tr) / 2;
			return f(get(2 * v, tl, tm, l, Math.min(r, tm)), get(2 * v + 1, tm + 1, tr, Math.max(l, tm + 1), r));
		}

		public void set(int v, int tl, int tr, int l, int r, long x) {
			push(v, tl, tr);
			if (l > tr || r < tl) {
				return;
			}
			if (l <= tl && r >= tr) {
				delta[v] += x;
				flag[v] = true;
				push(v, tl, tr);
				return;
			}
			int tm = (tl + tr) / 2;
			set(2 * v, tl, tm, l, r, x);
			set(2 * v + 1, tm + 1, tr, l, r, x);
			max[v] = f(max[2 * v], max[2 * v + 1]);
		}

		public void push(int v, int tl, int tr) {
			if (flag[v]) {
				if (v < pow) {
					flag[2 * v] = true;
					flag[2 * v + 1] = true;
					delta[2 * v] += delta[v];
					delta[2 * v + 1] += delta[v];
				}
				flag[v] = false;
				max[v] += delta[v];
				delta[v] = 0;
			}
		}

		public long f(long a, long b) {
			return Math.max(a, b);
		}
	}

	public class SegmentTreeSet {
		int pow;
		int[] sum;
		int[] delta;
		boolean[] flag;

		public SegmentTreeSet(int[] a) {
			pow = 1;
			while (pow < a.length) {
				pow *= 2;
			}
			flag = new boolean[2 * pow];
			sum = new int[2 * pow];
			delta = new int[2 * pow];
			for (int i = 0; i < a.length; i++) {
				sum[pow + i] = a[i];
			}
		}

		public int get(int v, int tl, int tr, int l, int r) {
			push(v, tl, tr);
			if (l > r) {
				return 0;
			}
			if (l == tl && r == tr) {
				return sum[v];
			}
			int tm = (tl + tr) / 2;
			return f(get(2 * v, tl, tm, l, Math.min(r, tm)), get(2 * v + 1, tm + 1, tr, Math.max(l, tm + 1), r));
		}

		public void set(int v, int tl, int tr, int l, int r, int x) {
			push(v, tl, tr);
			if (l > tr || r < tl) {
				return;
			}
			if (l <= tl && r >= tr) {
				delta[v] = x;
				flag[v] = true;
				push(v, tl, tr);
				return;
			}
			int tm = (tl + tr) / 2;
			set(2 * v, tl, tm, l, r, x);
			set(2 * v + 1, tm + 1, tr, l, r, x);
			sum[v] = f(sum[2 * v], sum[2 * v + 1]);
		}

		public void push(int v, int tl, int tr) {
			if (flag[v]) {
				if (v < pow) {
					flag[2 * v] = true;
					flag[2 * v + 1] = true;
					delta[2 * v] = delta[v];
					delta[2 * v + 1] = delta[v];
				}
				flag[v] = false;
				sum[v] = delta[v] * (tr - tl + 1);
			}
		}

		public int f(int a, int b) {
			return a + b;
		}
	}

	public class Pair implements Comparable<Pair> {
		int x;
		int y;

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

		public Pair clone() {
			return new Pair(x, y);
		}

		public String toString() {
			return x + " " + y;
		}

		@Override
		public int compareTo(Pair o) {
			if (y > o.y) {
				return 1;
			}
			if (y < o.y) {
				return -1;
			}
			if (x > o.x) {
				return 1;
			}
			if (x < o.x) {
				return -1;
			}
			return 0;
		}
	}

	long mod = 1000000007;
	Random random = new Random();

	public void shuffle(Pair[] a) {
		for (int i = 0; i < a.length; i++) {
			int x = random.nextInt(i + 1);
			Pair t = a[x];
			a[x] = a[i];
			a[i] = t;
		}
	}

	public void sort(int[][] a) {
		for (int i = 0; i < a.length; i++) {
			Arrays.sort(a[i]);
		}
	}

	public void add(HashMap<Long, Integer> map, long l) {
		if (map.containsKey(l)) {
			map.put(l, map.get(l) + 1);
		} else {
			map.put(l, 1);
		}
	}

	public void remove(TreeMap<Integer, Integer> map, Integer s) {
		if (map.get(s) > 1) {
			map.put(s, map.get(s) - 1);
		} else {
			map.remove(s);
		}
	}

	long max = Long.MAX_VALUE / 2;
	double eps = 1e-10;

	public int signum(double x) {
		if (x > eps) {
			return 1;
		}
		if (x < -eps) {
			return -1;
		}
		return 0;
	}

	public long abs(long x) {
		return x < 0 ? -x : x;
	}

	public long min(long x, long y) {
		return x < y ? x : y;
	}

	public long max(long x, long y) {
		return x > y ? x : y;
	}

	public long gcd(long x, long y) {
		while (y > 0) {
			long c = y;
			y = x % y;
			x = c;
		}
		return x;
	}

	public final Vector ZERO = new Vector(0, 0);

	// public class Vector implements Comparable<Vector> {
	// long x;
	// long y;
	// int type;
	// int number;
	//
	// public Vector() {
	// x = 0;
	// y = 0;
	// }
	//
	// public Vector(long x, long y, int type, int number) {
	// this.x = x;
	// this.y = y;
	// this.type = type;
	// this.number = number;
	// }
	//
	// public Vector(long x, long y) {
	//
	// }
	//
	// public Vector(Point begin, Point end) {
	// this(end.x - begin.x, end.y - begin.y);
	// }
	//
	// public void orient() {
	// if (x < 0) {
	// x = -x;
	// y = -y;
	// }
	// if (x == 0 && y < 0) {
	// y = -y;
	// }
	// }
	//
	// public void normalize() {
	// long gcd = gcd(abs(x), abs(y));
	// x /= gcd;
	// y /= gcd;
	// }
	//
	// public String toString() {
	// return x + " " + y;
	// }
	//
	// public boolean equals(Vector v) {
	// return x == v.x && y == v.y;
	// }
	//
	// public boolean collinear(Vector v) {
	// return cp(this, v) == 0;
	// }
	//
	// public boolean orthogonal(Vector v) {
	// return dp(this, v) == 0;
	// }
	//
	// public Vector ort(Vector v) {
	// return new Vector(-y, x);
	// }
	//
	// public Vector add(Vector v) {
	// return new Vector(x + v.x, y + v.y);
	// }
	//
	// public Vector multiply(long c) {
	// return new Vector(c * x, c * y);
	// }
	//
	// public int quater() {
	// if (x > 0 && y >= 0) {
	// return 1;
	// }
	// if (x <= 0 && y > 0) {
	// return 2;
	// }
	// if (x < 0) {
	// return 3;
	// }
	// return 0;
	// }
	//
	// public long len2() {
	// return x * x + y * y;
	// }
	//
	// @Override
	// public int compareTo(Vector o) {
	// if (quater() != o.quater()) {
	// return quater() - o.quater();
	// }
	// return signum(cp(o, this));
	// }
	// }

	// public long dp(Vector v1, Vector v2) {
	// return v1.x * v2.x + v1.y * v2.y;
	// }
	//
	// public long cp(Vector v1, Vector v2) {
	// return v1.x * v2.y - v1.y * v2.x;
	// }

	// public class Line implements Comparable<Line> {
	// Point p;
	// Vector v;
	//
	// public Line(Point p, Vector v) {
	// this.p = p;
	// this.v = v;
	// }
	//
	// public Line(Point p1, Point p2) {
	// if (p1.compareTo(p2) < 0) {
	// p = p1;
	// v = new Vector(p1, p2);
	// } else {
	// p = p2;
	// v = new Vector();
	// }
	// }
	//
	// public boolean collinear(Line l) {
	// return v.collinear(l.v);
	// }
	//
	// public boolean inLine(Point p) {
	// return hv(p) == 0;
	// }
	//
	// public boolean inSegment(Point p) {
	// if (!inLine(p)) {
	// return false;
	// }
	// Point p1 = p;
	// Point p2 = p.add(v);
	// return p1.x <= p.x && p.x <= p2.x && min(p1.y, p2.y) <= p.y && p.y <=
	// max(p1.y, p2.y);
	// }
	//
	// public boolean equalsSegment(Line l) {
	// return p.equals(l.p) && v.equals(l.v);
	// }
	//
	// public boolean equalsLine(Line l) {
	// return collinear(l) && inLine(l.p);
	// }
	//
	// public long hv(Point p) {
	// Vector v1 = new Vector(this.p, p);
	// return cp(v, v1);
	// }
	//
	// public double h(Point p) {
	// Vector v1 = new Vector(this.p, p);
	// return cp(v, v1) / Math.sqrt(v.len2());
	// }
	//
	// public long[] intersectLines(Line l) {
	// if (collinear(l)) {
	// return null;
	// }
	// long[] ans = new long[4];
	//
	// return ans;
	// }
	//
	// public long[] intersectSegment(Line l) {
	// long[] ans = intersectLines(l);
	// if (ans == null) {
	// return null;
	// }
	// Point p1 = p;
	// Point p2 = p.add(v);
	// boolean f1 = p1.x * ans[1] <= ans[0] && ans[0] <= p2.x * ans[1] && min(p1.y,
	// p2.y) * ans[3] <= ans[2]
	// && ans[2] <= max(p1.y, p2.y) * ans[3];
	// p1 = l.p;
	// p2 = l.p.add(v);
	// boolean f2 = p1.x * ans[1] <= ans[0] && ans[0] <= p2.x * ans[1] && min(p1.y,
	// p2.y) * ans[3] <= ans[2]
	// && ans[2] <= max(p1.y, p2.y) * ans[3];
	// if (!f1 || !f2) {
	// return null;
	// }
	// return ans;
	// }
	//
	// @Override
	// public int compareTo(Line o) {
	// return v.compareTo(o.v);
	// }
	// }

	public class Rect {
		long x1;
		long x2;
		long y1;
		long y2;
		int number;

		public Rect(long x1, long x2, long y1, long y2, int number) {
			this.x1 = x1;
			this.x2 = x2;
			this.y1 = y1;
			this.y2 = y2;
			this.number = number;
		}
	}

	public static class Fenvik {
		int[] t;

		public Fenvik(int n) {
			t = new int[n];
		}

		public void add(int x, int delta) {
			for (int i = x; i < t.length; i = (i | (i + 1))) {
				t[i] += delta;
			}
		}

		private int sum(int r) {
			int ans = 0;
			int x = r;
			while (x >= 0) {
				ans += t[x];
				x = (x & (x + 1)) - 1;
			}
			return ans;
		}

		public int sum(int l, int r) {
			return sum(r) - sum(l - 1);
		}
	}

	public class SegmentTreeMaxSum {
		int pow;
		int[] sum;
		int[] maxPrefSum;
		int[] maxSufSum;
		int[] maxSum;

		public SegmentTreeMaxSum(int[] a) {
			pow = 1;
			while (pow < a.length) {
				pow *= 2;
			}
			sum = new int[2 * pow];
			maxPrefSum = new int[2 * pow];
			maxSum = new int[2 * pow];
			maxSufSum = new int[2 * pow];
			for (int i = 0; i < a.length; i++) {
				sum[pow + i] = a[i];
				maxSum[pow + i] = Math.max(a[i], 0);
				maxPrefSum[pow + i] = maxSum[pow + i];
				maxSufSum[pow + i] = maxSum[pow + i];
			}
			for (int i = pow - 1; i > 0; i--) {
				update(i);
			}
		}

		public int[] get(int v, int tl, int tr, int l, int r) {
			if (r <= tl || l >= tr) {
				int[] ans = { 0, 0, 0, 0 };
				return ans;
			}
			if (l <= tl && r >= tr) {
				int[] ans = { maxPrefSum[v], maxSum[v], maxSufSum[v], sum[v] };
				return ans;
			}
			int tm = (tl + tr) / 2;
			int[] left = get(2 * v, tl, tm, l, r);
			int[] right = get(2 * v + 1, tm, tr, l, r);
			int[] ans = { Math.max(left[0], right[0] + left[3]),
					Math.max(left[1], Math.max(right[1], left[2] + right[0])), Math.max(right[2], left[2] + right[3]),
					left[3] + right[3] };
			return ans;
		}

		public void set(int v, int tl, int tr, int x, int value) {
			if (v >= pow) {
				sum[v] = value;
				maxSum[v] = Math.max(value, 0);
				maxPrefSum[v] = maxSum[v];
				maxSufSum[v] = maxSum[v];
				return;
			}
			int tm = (tl + tr) / 2;
			if (x < tm) {
				set(2 * v, tl, tm, x, value);
			} else {
				set(2 * v + 1, tm, tr, x, value);
			}
			update(v);
		}

		public void update(int i) {
			sum[i] = f(sum[2 * i], sum[2 * i + 1]);
			maxSum[i] = Math.max(maxSum[2 * i], Math.max(maxSum[2 * i + 1], maxSufSum[2 * i] + maxPrefSum[2 * i + 1]));
			maxPrefSum[i] = Math.max(maxPrefSum[2 * i], maxPrefSum[2 * i + 1] + sum[2 * i]);
			maxSufSum[i] = Math.max(maxSufSum[2 * i + 1], maxSufSum[2 * i] + sum[2 * i + 1]);
		}

		public int f(int a, int b) {
			return a + b;
		}
	}

	public class Point implements Comparable<Point> {
		double x;
		double y;

		public Point() {
			x = 0;
			y = 0;
		}

		public Point(double x, double y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Point p) {
			return x == p.x && y == p.y;
		}

		public double dist2() {
			return x * x + y * y;
		}

		public Point add(Point v) {
			return new Point(x + v.x, y + v.y);
		}

		@Override
		public int compareTo(Point o) {
			int z = signum(x + y - o.x - o.y);
			if (z != 0) {
				return z;
			}
			return signum(x - o.x) != 0 ? signum(x - o.x) : signum(y - o.y);
		}
	}

	public class Circle implements Comparable<Circle> {
		Point p;
		int r;

		public Circle(Point p, int r) {
			this.p = p;
			this.r = r;
		}

		public Point angle() {
			double z = r / sq2;
			z -= z % 1e-5;
			return new Point(p.x - z, p.y - z);
		}

		public boolean inside(Point p) {
			return hypot2(p.x - this.p.x, p.y - this.p.y) <= sq(r);
		}

		@Override
		public int compareTo(Circle o) {
			Point a = angle();
			Point oa = o.angle();
			int z = signum(a.x + a.y - oa.x - oa.y);
			if (z != 0) {
				return z;
			}
			return signum(a.y - oa.y);
		}

	}

	public class Fraction implements Comparable<Fraction> {
		long x;
		long y;

		public Fraction(long x, long y, boolean needNorm) {
			this.x = x;
			this.y = y;
			if (y < 0) {
				this.x *= -1;
				this.y *= -1;
			}
			if (needNorm) {
				long gcd = gcd(this.x, this.y);
				this.x /= gcd;
				this.y /= gcd;
			}
		}

		public Fraction clone() {
			return new Fraction(x, y, false);
		}

		public String toString() {
			return x + "/" + y;
		}

		@Override
		public int compareTo(Fraction o) {
			long res = x * o.y - y * o.x;
			if (res > 0) {
				return 1;
			}
			if (res < 0) {
				return -1;
			}
			return 0;
		}
	}

	public class Event implements Comparable<Event> {
		Fraction f;
		int type;

		public Event(Fraction f, int type) {
			this.f = f;
			this.type = type;
		}

		@Override
		public int compareTo(Event o) {
			int c = f.compareTo(o.f);
			if (c != 0) {
				return c;
			}
			return type - o.type;
		}

	}

	public double sq(double x) {
		return x * x;
	}

	public long sq(long x) {
		return x * x;
	}

	public double hypot2(double x, double y) {
		return sq(x) + sq(y);
	}

	public long hypot2(long x, long y) {
		return sq(x) + sq(y);
	}

	public boolean kuhn(int v, int[][] edge, boolean[] used, int[] mt) {
		used[v] = true;
		for (int u : edge[v]) {
			if (mt[u] < 0 || (!used[mt[u]] && kuhn(mt[u], edge, used, mt))) {
				mt[u] = v;
				return true;
			}
		}
		return false;
	}

	public int matching(int[][] edge) {
		int n = edge.length;
		int[] mt = new int[n];
		Arrays.fill(mt, -1);
		boolean[] used = new boolean[n];
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (!used[i] && kuhn(i, edge, used, mt)) {
				Arrays.fill(used, false);
				ans++;
			}
		}
		return ans;
	}

	double sq2 = Math.sqrt(2);

	int small = 20;

	public class Stack {
		int[] st;
		int sz;

		public Stack(int n) {
			this.st = new int[n];
			sz = 0;
		}

		public boolean isEmpty() {
			return sz == 0;
		}

		public int peek() {
			return st[sz - 1];
		}

		public int pop() {
			sz--;
			return st[sz];
		}

		public void clear() {
			sz = 0;
		}

		public void add(int x) {
			st[sz++] = x;
		}

		public int get(int x) {
			return st[x];
		}
	}

	public int[][] readGraph(int n, int m) {
		int[][] to = new int[n][];
		int[] sz = new int[n];
		int[] x = new int[m];
		int[] y = new int[m];
		for (int i = 0; i < m; i++) {
			x[i] = in.nextInt() - 1;
			y[i] = in.nextInt() - 1;
			sz[x[i]]++;
			sz[y[i]]++;
		}
		for (int i = 0; i < to.length; i++) {
			to[i] = new int[sz[i]];
			sz[i] = 0;
		}
		for (int i = 0; i < x.length; i++) {
			to[x[i]][sz[x[i]]++] = y[i];
			to[y[i]][sz[y[i]]++] = x[i];
		}
		return to;
	}

	public class Pol {
		double[] coeff;

		public Pol(double[] coeff) {
			this.coeff = coeff;
		}

		public Pol mult(Pol p) {
			double[] ans = new double[coeff.length + p.coeff.length - 1];
			for (int i = 0; i < ans.length; i++) {
				for (int j = Math.max(0, i - p.coeff.length + 1); j < coeff.length && j <= i; j++) {
					ans[i] += coeff[j] * p.coeff[i - j];
				}
			}
			return new Pol(ans);
		}

		public String toString() {
			String ans = "";
			for (int i = 0; i < coeff.length; i++) {
				ans += coeff[i] + " ";
			}
			return ans;
		}

		public double value(double x) {
			double ans = 0;
			double p = 1;
			for (int i = 0; i < coeff.length; i++) {
				ans += coeff[i] * p;
				p *= x;
			}
			return ans;
		}

		public double integrate(double r) {
			Pol p = new Pol(new double[coeff.length + 1]);
			for (int i = 0; i < coeff.length; i++) {
				p.coeff[i + 1] = coeff[i] / fact[i + 1];
			}
			return p.value(r);
		}

		public double integrate(double l, double r) {
			return integrate(r) - integrate(l);
		}
	}

	double[] fact = new double[100];

	public class DSU1 {
		int[] p;
		int[] sz;
		Stack less;
		Stack more;
		TreeSet<Integer>[] q;
		boolean[] used;

		@SuppressWarnings("unchecked")
		public DSU1(int[] v, int m) {
			int n = v.length;
			p = new int[n];
			sz = new int[n];
			q = new TreeSet[n];
			less = new Stack(m);
			more = new Stack(m);
			used = new boolean[n + 1];
			for (int i = 0; i < v.length; i++) {
				p[i] = i;
				sz[i] = 1;
				q[i] = new TreeSet<>();
				q[i].add(v[i]);
			}
		}

		public int get(int x) {
			while (x != p[x]) {
				x = p[x];
			}
			return x;
		}

		public boolean unite(int a, int b) {
			int pa = get(a);
			int pb = get(b);
			if (pa == pb) {
				return false;
			}
			if (sz[pa] < sz[pb]) {
				p[pa] = pb;
				sz[pb] += sz[pa];

				less.add(pa);
				more.add(pb);
				for (int i : q[pa]) {
					q[pb].add(i);
				}
			} else {
				p[pb] = pa;
				sz[pa] += sz[pb];

				less.add(pb);
				more.add(pa);
				for (int i : q[pb]) {
					q[pa].add(i);
				}
			}
			return true;
		}

		public void popEdge() {
			int pa = less.pop();
			int pb = more.pop();
			for (int i : q[pa]) {
				q[pb].remove(i);
			}
			p[pa] = pa;
			sz[pb] -= sz[pa];
		}

		public int poll(int x) {
			int px = get(x);
			while (!q[px].isEmpty()) {
				int v = q[px].pollLast();
				if (!used[v]) {
					used[v] = true;
					return v;
				}
			}
			return 0;
		}

	}

	public void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		int q = in.nextInt();
		int[] v = new int[n];
		for (int i = 0; i < v.length; i++) {
			v[i] = in.nextInt();
		}
		int[] a = new int[m];
		int[] b = new int[m];
		for (int i = 0; i < b.length; i++) {
			a[i] = in.nextInt() - 1;
			b[i] = in.nextInt() - 1;
		}
		boolean[] type = new boolean[q];
		int[] x = new int[q];
		boolean[] removed = new boolean[m];
		for (int i = 0; i < q; i++) {
			if (in.nextInt() == 1) {
				x[i] = in.nextInt() - 1;
				type[i] = true;
			} else {
				x[i] = in.nextInt() - 1;
				removed[x[i]] = true;
			}
		}
		DSU1 dsu = new DSU1(v, m);
		for (int i = 0; i < removed.length; i++) {
			if (!removed[i]) {
				dsu.unite(a[i], b[i]);
			}
		}
		for (int i = q - 1; i >= 0; i--) {
			if (!type[i]) {
				dsu.unite(a[x[i]], b[x[i]]);
			}
		}
		for (int i = 0; i < q; i++) {
			if (type[i]) {
				out.println(dsu.poll(x[i]));
			} else {
				dsu.popEdge();
			}
		}
	}

	public void add(HashMap<Integer, Integer> map, int x) {
		if (map.containsKey(x)) {
			map.put(x, map.get(x) + 1);
		} else {
			map.put(x, 1);
		}
	}

	public void run() {
		try {
			if (systemIO) {
				in = new FastScanner(System.in);
				out = new PrintWriter(System.out);
			} else {
				in = new FastScanner(new File("input.txt"));
				out = new PrintWriter(new File("output.txt"));
			}
			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

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

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

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

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

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

	}

	// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
	public static void main(String[] arg) {
		new E().run();
	}
}


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

public class E {
	FastScanner in;
	PrintWriter out;
	boolean systemIO = true;

	public class DSU {
		int[] sz;
		int[] p;

		public DSU(int n) {
			sz = new int[n];
			p = new int[n];
			for (int i = 0; i < p.length; i++) {
				p[i] = i;
				sz[i] = 1;
			}
		}

		public int get(int x) {
			if (x == p[x]) {
				return x;
			}
			int par = get(p[x]);
			p[x] = par;
			return par;
		}

		public boolean unite(int a, int b) {
			int pa = get(a);
			int pb = get(b);
			if (pa == pb) {
				return false;
			}
			if (sz[pa] < sz[pb]) {
				p[pa] = pb;
				sz[pb] += sz[pa];
			} else {
				p[pb] = pa;
				sz[pa] += sz[pb];
			}
			return true;
		}
	}

	public class SegmentTreeAdd {
		int pow;
		long[] max;
		long[] delta;
		boolean[] flag;

		public SegmentTreeAdd(long[] a) {
			pow = 1;
			while (pow < a.length) {
				pow *= 2;
			}
			flag = new boolean[2 * pow];
			max = new long[2 * pow];
			delta = new long[2 * pow];
			for (int i = 0; i < max.length; i++) {
				max[i] = Long.MIN_VALUE / 2;
			}
			for (int i = 0; i < a.length; i++) {
				max[pow + i] = a[i];
			}
			for (int i = pow - 1; i > 0; i--) {
				max[i] = f(max[2 * i], max[2 * i + 1]);
			}
		}

		public long get(int v, int tl, int tr, int l, int r) {
			push(v, tl, tr);
			if (l > r) {
				return Long.MIN_VALUE / 2;
			}
			if (l == tl && r == tr) {
				return max[v];
			}
			int tm = (tl + tr) / 2;
			return f(get(2 * v, tl, tm, l, Math.min(r, tm)), get(2 * v + 1, tm + 1, tr, Math.max(l, tm + 1), r));
		}

		public void set(int v, int tl, int tr, int l, int r, long x) {
			push(v, tl, tr);
			if (l > tr || r < tl) {
				return;
			}
			if (l <= tl && r >= tr) {
				delta[v] += x;
				flag[v] = true;
				push(v, tl, tr);
				return;
			}
			int tm = (tl + tr) / 2;
			set(2 * v, tl, tm, l, r, x);
			set(2 * v + 1, tm + 1, tr, l, r, x);
			max[v] = f(max[2 * v], max[2 * v + 1]);
		}

		public void push(int v, int tl, int tr) {
			if (flag[v]) {
				if (v < pow) {
					flag[2 * v] = true;
					flag[2 * v + 1] = true;
					delta[2 * v] += delta[v];
					delta[2 * v + 1] += delta[v];
				}
				flag[v] = false;
				max[v] += delta[v];
				delta[v] = 0;
			}
		}

		public long f(long a, long b) {
			return Math.max(a, b);
		}
	}

	public class SegmentTreeSet {
		int pow;
		int[] sum;
		int[] delta;
		boolean[] flag;

		public SegmentTreeSet(int[] a) {
			pow = 1;
			while (pow < a.length) {
				pow *= 2;
			}
			flag = new boolean[2 * pow];
			sum = new int[2 * pow];
			delta = new int[2 * pow];
			for (int i = 0; i < a.length; i++) {
				sum[pow + i] = a[i];
			}
		}

		public int get(int v, int tl, int tr, int l, int r) {
			push(v, tl, tr);
			if (l > r) {
				return 0;
			}
			if (l == tl && r == tr) {
				return sum[v];
			}
			int tm = (tl + tr) / 2;
			return f(get(2 * v, tl, tm, l, Math.min(r, tm)), get(2 * v + 1, tm + 1, tr, Math.max(l, tm + 1), r));
		}

		public void set(int v, int tl, int tr, int l, int r, int x) {
			push(v, tl, tr);
			if (l > tr || r < tl) {
				return;
			}
			if (l <= tl && r >= tr) {
				delta[v] = x;
				flag[v] = true;
				push(v, tl, tr);
				return;
			}
			int tm = (tl + tr) / 2;
			set(2 * v, tl, tm, l, r, x);
			set(2 * v + 1, tm + 1, tr, l, r, x);
			sum[v] = f(sum[2 * v], sum[2 * v + 1]);
		}

		public void push(int v, int tl, int tr) {
			if (flag[v]) {
				if (v < pow) {
					flag[2 * v] = true;
					flag[2 * v + 1] = true;
					delta[2 * v] = delta[v];
					delta[2 * v + 1] = delta[v];
				}
				flag[v] = false;
				sum[v] = delta[v] * (tr - tl + 1);
			}
		}

		public int f(int a, int b) {
			return a + b;
		}
	}

	public class Pair implements Comparable<Pair> {
		int x;
		int y;

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

		public Pair clone() {
			return new Pair(x, y);
		}

		public String toString() {
			return x + " " + y;
		}

		@Override
		public int compareTo(Pair o) {
			if (y > o.y) {
				return 1;
			}
			if (y < o.y) {
				return -1;
			}
			if (x > o.x) {
				return 1;
			}
			if (x < o.x) {
				return -1;
			}
			return 0;
		}
	}

	long mod = 1000000007;
	Random random = new Random();

	public void shuffle(Pair[] a) {
		for (int i = 0; i < a.length; i++) {
			int x = random.nextInt(i + 1);
			Pair t = a[x];
			a[x] = a[i];
			a[i] = t;
		}
	}

	public void sort(int[][] a) {
		for (int i = 0; i < a.length; i++) {
			Arrays.sort(a[i]);
		}
	}

	public void add(HashMap<Long, Integer> map, long l) {
		if (map.containsKey(l)) {
			map.put(l, map.get(l) + 1);
		} else {
			map.put(l, 1);
		}
	}

	public void remove(TreeMap<Integer, Integer> map, Integer s) {
		if (map.get(s) > 1) {
			map.put(s, map.get(s) - 1);
		} else {
			map.remove(s);
		}
	}

	long max = Long.MAX_VALUE / 2;
	double eps = 1e-10;

	public int signum(double x) {
		if (x > eps) {
			return 1;
		}
		if (x < -eps) {
			return -1;
		}
		return 0;
	}

	public long abs(long x) {
		return x < 0 ? -x : x;
	}

	public long min(long x, long y) {
		return x < y ? x : y;
	}

	public long max(long x, long y) {
		return x > y ? x : y;
	}

	public long gcd(long x, long y) {
		while (y > 0) {
			long c = y;
			y = x % y;
			x = c;
		}
		return x;
	}

	public final Vector ZERO = new Vector(0, 0);

	// public class Vector implements Comparable<Vector> {
	// long x;
	// long y;
	// int type;
	// int number;
	//
	// public Vector() {
	// x = 0;
	// y = 0;
	// }
	//
	// public Vector(long x, long y, int type, int number) {
	// this.x = x;
	// this.y = y;
	// this.type = type;
	// this.number = number;
	// }
	//
	// public Vector(long x, long y) {
	//
	// }
	//
	// public Vector(Point begin, Point end) {
	// this(end.x - begin.x, end.y - begin.y);
	// }
	//
	// public void orient() {
	// if (x < 0) {
	// x = -x;
	// y = -y;
	// }
	// if (x == 0 && y < 0) {
	// y = -y;
	// }
	// }
	//
	// public void normalize() {
	// long gcd = gcd(abs(x), abs(y));
	// x /= gcd;
	// y /= gcd;
	// }
	//
	// public String toString() {
	// return x + " " + y;
	// }
	//
	// public boolean equals(Vector v) {
	// return x == v.x && y == v.y;
	// }
	//
	// public boolean collinear(Vector v) {
	// return cp(this, v) == 0;
	// }
	//
	// public boolean orthogonal(Vector v) {
	// return dp(this, v) == 0;
	// }
	//
	// public Vector ort(Vector v) {
	// return new Vector(-y, x);
	// }
	//
	// public Vector add(Vector v) {
	// return new Vector(x + v.x, y + v.y);
	// }
	//
	// public Vector multiply(long c) {
	// return new Vector(c * x, c * y);
	// }
	//
	// public int quater() {
	// if (x > 0 && y >= 0) {
	// return 1;
	// }
	// if (x <= 0 && y > 0) {
	// return 2;
	// }
	// if (x < 0) {
	// return 3;
	// }
	// return 0;
	// }
	//
	// public long len2() {
	// return x * x + y * y;
	// }
	//
	// @Override
	// public int compareTo(Vector o) {
	// if (quater() != o.quater()) {
	// return quater() - o.quater();
	// }
	// return signum(cp(o, this));
	// }
	// }

	// public long dp(Vector v1, Vector v2) {
	// return v1.x * v2.x + v1.y * v2.y;
	// }
	//
	// public long cp(Vector v1, Vector v2) {
	// return v1.x * v2.y - v1.y * v2.x;
	// }

	// public class Line implements Comparable<Line> {
	// Point p;
	// Vector v;
	//
	// public Line(Point p, Vector v) {
	// this.p = p;
	// this.v = v;
	// }
	//
	// public Line(Point p1, Point p2) {
	// if (p1.compareTo(p2) < 0) {
	// p = p1;
	// v = new Vector(p1, p2);
	// } else {
	// p = p2;
	// v = new Vector();
	// }
	// }
	//
	// public boolean collinear(Line l) {
	// return v.collinear(l.v);
	// }
	//
	// public boolean inLine(Point p) {
	// return hv(p) == 0;
	// }
	//
	// public boolean inSegment(Point p) {
	// if (!inLine(p)) {
	// return false;
	// }
	// Point p1 = p;
	// Point p2 = p.add(v);
	// return p1.x <= p.x && p.x <= p2.x && min(p1.y, p2.y) <= p.y && p.y <=
	// max(p1.y, p2.y);
	// }
	//
	// public boolean equalsSegment(Line l) {
	// return p.equals(l.p) && v.equals(l.v);
	// }
	//
	// public boolean equalsLine(Line l) {
	// return collinear(l) && inLine(l.p);
	// }
	//
	// public long hv(Point p) {
	// Vector v1 = new Vector(this.p, p);
	// return cp(v, v1);
	// }
	//
	// public double h(Point p) {
	// Vector v1 = new Vector(this.p, p);
	// return cp(v, v1) / Math.sqrt(v.len2());
	// }
	//
	// public long[] intersectLines(Line l) {
	// if (collinear(l)) {
	// return null;
	// }
	// long[] ans = new long[4];
	//
	// return ans;
	// }
	//
	// public long[] intersectSegment(Line l) {
	// long[] ans = intersectLines(l);
	// if (ans == null) {
	// return null;
	// }
	// Point p1 = p;
	// Point p2 = p.add(v);
	// boolean f1 = p1.x * ans[1] <= ans[0] && ans[0] <= p2.x * ans[1] && min(p1.y,
	// p2.y) * ans[3] <= ans[2]
	// && ans[2] <= max(p1.y, p2.y) * ans[3];
	// p1 = l.p;
	// p2 = l.p.add(v);
	// boolean f2 = p1.x * ans[1] <= ans[0] && ans[0] <= p2.x * ans[1] && min(p1.y,
	// p2.y) * ans[3] <= ans[2]
	// && ans[2] <= max(p1.y, p2.y) * ans[3];
	// if (!f1 || !f2) {
	// return null;
	// }
	// return ans;
	// }
	//
	// @Override
	// public int compareTo(Line o) {
	// return v.compareTo(o.v);
	// }
	// }

	public class Rect {
		long x1;
		long x2;
		long y1;
		long y2;
		int number;

		public Rect(long x1, long x2, long y1, long y2, int number) {
			this.x1 = x1;
			this.x2 = x2;
			this.y1 = y1;
			this.y2 = y2;
			this.number = number;
		}
	}

	public static class Fenvik {
		int[] t;

		public Fenvik(int n) {
			t = new int[n];
		}

		public void add(int x, int delta) {
			for (int i = x; i < t.length; i = (i | (i + 1))) {
				t[i] += delta;
			}
		}

		private int sum(int r) {
			int ans = 0;
			int x = r;
			while (x >= 0) {
				ans += t[x];
				x = (x & (x + 1)) - 1;
			}
			return ans;
		}

		public int sum(int l, int r) {
			return sum(r) - sum(l - 1);
		}
	}

	public class SegmentTreeMaxSum {
		int pow;
		int[] sum;
		int[] maxPrefSum;
		int[] maxSufSum;
		int[] maxSum;

		public SegmentTreeMaxSum(int[] a) {
			pow = 1;
			while (pow < a.length) {
				pow *= 2;
			}
			sum = new int[2 * pow];
			maxPrefSum = new int[2 * pow];
			maxSum = new int[2 * pow];
			maxSufSum = new int[2 * pow];
			for (int i = 0; i < a.length; i++) {
				sum[pow + i] = a[i];
				maxSum[pow + i] = Math.max(a[i], 0);
				maxPrefSum[pow + i] = maxSum[pow + i];
				maxSufSum[pow + i] = maxSum[pow + i];
			}
			for (int i = pow - 1; i > 0; i--) {
				update(i);
			}
		}

		public int[] get(int v, int tl, int tr, int l, int r) {
			if (r <= tl || l >= tr) {
				int[] ans = { 0, 0, 0, 0 };
				return ans;
			}
			if (l <= tl && r >= tr) {
				int[] ans = { maxPrefSum[v], maxSum[v], maxSufSum[v], sum[v] };
				return ans;
			}
			int tm = (tl + tr) / 2;
			int[] left = get(2 * v, tl, tm, l, r);
			int[] right = get(2 * v + 1, tm, tr, l, r);
			int[] ans = { Math.max(left[0], right[0] + left[3]),
					Math.max(left[1], Math.max(right[1], left[2] + right[0])), Math.max(right[2], left[2] + right[3]),
					left[3] + right[3] };
			return ans;
		}

		public void set(int v, int tl, int tr, int x, int value) {
			if (v >= pow) {
				sum[v] = value;
				maxSum[v] = Math.max(value, 0);
				maxPrefSum[v] = maxSum[v];
				maxSufSum[v] = maxSum[v];
				return;
			}
			int tm = (tl + tr) / 2;
			if (x < tm) {
				set(2 * v, tl, tm, x, value);
			} else {
				set(2 * v + 1, tm, tr, x, value);
			}
			update(v);
		}

		public void update(int i) {
			sum[i] = f(sum[2 * i], sum[2 * i + 1]);
			maxSum[i] = Math.max(maxSum[2 * i], Math.max(maxSum[2 * i + 1], maxSufSum[2 * i] + maxPrefSum[2 * i + 1]));
			maxPrefSum[i] = Math.max(maxPrefSum[2 * i], maxPrefSum[2 * i + 1] + sum[2 * i]);
			maxSufSum[i] = Math.max(maxSufSum[2 * i + 1], maxSufSum[2 * i] + sum[2 * i + 1]);
		}

		public int f(int a, int b) {
			return a + b;
		}
	}

	public class Point implements Comparable<Point> {
		double x;
		double y;

		public Point() {
			x = 0;
			y = 0;
		}

		public Point(double x, double y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Point p) {
			return x == p.x && y == p.y;
		}

		public double dist2() {
			return x * x + y * y;
		}

		public Point add(Point v) {
			return new Point(x + v.x, y + v.y);
		}

		@Override
		public int compareTo(Point o) {
			int z = signum(x + y - o.x - o.y);
			if (z != 0) {
				return z;
			}
			return signum(x - o.x) != 0 ? signum(x - o.x) : signum(y - o.y);
		}
	}

	public class Circle implements Comparable<Circle> {
		Point p;
		int r;

		public Circle(Point p, int r) {
			this.p = p;
			this.r = r;
		}

		public Point angle() {
			double z = r / sq2;
			z -= z % 1e-5;
			return new Point(p.x - z, p.y - z);
		}

		public boolean inside(Point p) {
			return hypot2(p.x - this.p.x, p.y - this.p.y) <= sq(r);
		}

		@Override
		public int compareTo(Circle o) {
			Point a = angle();
			Point oa = o.angle();
			int z = signum(a.x + a.y - oa.x - oa.y);
			if (z != 0) {
				return z;
			}
			return signum(a.y - oa.y);
		}

	}

	public class Fraction implements Comparable<Fraction> {
		long x;
		long y;

		public Fraction(long x, long y, boolean needNorm) {
			this.x = x;
			this.y = y;
			if (y < 0) {
				this.x *= -1;
				this.y *= -1;
			}
			if (needNorm) {
				long gcd = gcd(this.x, this.y);
				this.x /= gcd;
				this.y /= gcd;
			}
		}

		public Fraction clone() {
			return new Fraction(x, y, false);
		}

		public String toString() {
			return x + "/" + y;
		}

		@Override
		public int compareTo(Fraction o) {
			long res = x * o.y - y * o.x;
			if (res > 0) {
				return 1;
			}
			if (res < 0) {
				return -1;
			}
			return 0;
		}
	}

	public class Event implements Comparable<Event> {
		Fraction f;
		int type;

		public Event(Fraction f, int type) {
			this.f = f;
			this.type = type;
		}

		@Override
		public int compareTo(Event o) {
			int c = f.compareTo(o.f);
			if (c != 0) {
				return c;
			}
			return type - o.type;
		}

	}

	public double sq(double x) {
		return x * x;
	}

	public long sq(long x) {
		return x * x;
	}

	public double hypot2(double x, double y) {
		return sq(x) + sq(y);
	}

	public long hypot2(long x, long y) {
		return sq(x) + sq(y);
	}

	public boolean kuhn(int v, int[][] edge, boolean[] used, int[] mt) {
		used[v] = true;
		for (int u : edge[v]) {
			if (mt[u] < 0 || (!used[mt[u]] && kuhn(mt[u], edge, used, mt))) {
				mt[u] = v;
				return true;
			}
		}
		return false;
	}

	public int matching(int[][] edge) {
		int n = edge.length;
		int[] mt = new int[n];
		Arrays.fill(mt, -1);
		boolean[] used = new boolean[n];
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (!used[i] && kuhn(i, edge, used, mt)) {
				Arrays.fill(used, false);
				ans++;
			}
		}
		return ans;
	}

	double sq2 = Math.sqrt(2);

	int small = 20;

	public class Stack {
		int[] st;
		int sz;

		public Stack(int n) {
			this.st = new int[n];
			sz = 0;
		}

		public boolean isEmpty() {
			return sz == 0;
		}

		public int peek() {
			return st[sz - 1];
		}

		public int pop() {
			sz--;
			return st[sz];
		}

		public void clear() {
			sz = 0;
		}

		public void add(int x) {
			st[sz++] = x;
		}

		public int get(int x) {
			return st[x];
		}
	}

	public int[][] readGraph(int n, int m) {
		int[][] to = new int[n][];
		int[] sz = new int[n];
		int[] x = new int[m];
		int[] y = new int[m];
		for (int i = 0; i < m; i++) {
			x[i] = in.nextInt() - 1;
			y[i] = in.nextInt() - 1;
			sz[x[i]]++;
			sz[y[i]]++;
		}
		for (int i = 0; i < to.length; i++) {
			to[i] = new int[sz[i]];
			sz[i] = 0;
		}
		for (int i = 0; i < x.length; i++) {
			to[x[i]][sz[x[i]]++] = y[i];
			to[y[i]][sz[y[i]]++] = x[i];
		}
		return to;
	}

	public class Pol {
		double[] coeff;

		public Pol(double[] coeff) {
			this.coeff = coeff;
		}

		public Pol mult(Pol p) {
			double[] ans = new double[coeff.length + p.coeff.length - 1];
			for (int i = 0; i < ans.length; i++) {
				for (int j = Math.max(0, i - p.coeff.length + 1); j < coeff.length && j <= i; j++) {
					ans[i] += coeff[j] * p.coeff[i - j];
				}
			}
			return new Pol(ans);
		}

		public String toString() {
			String ans = "";
			for (int i = 0; i < coeff.length; i++) {
				ans += coeff[i] + " ";
			}
			return ans;
		}

		public double value(double x) {
			double ans = 0;
			double p = 1;
			for (int i = 0; i < coeff.length; i++) {
				ans += coeff[i] * p;
				p *= x;
			}
			return ans;
		}

		public double integrate(double r) {
			Pol p = new Pol(new double[coeff.length + 1]);
			for (int i = 0; i < coeff.length; i++) {
				p.coeff[i + 1] = coeff[i] / fact[i + 1];
			}
			return p.value(r);
		}

		public double integrate(double l, double r) {
			return integrate(r) - integrate(l);
		}
	}

	double[] fact = new double[100];

	public class DSU1 {
		int[] p;
		int[] sz;
		Stack less;
		Stack more;
		TreeSet<Integer>[] q;
		boolean[] used;

		@SuppressWarnings("unchecked")
		public DSU1(int[] v, int m) {
			int n = v.length;
			p = new int[n];
			sz = new int[n];
			q = new TreeSet[n];
			less = new Stack(m);
			more = new Stack(m);
			used = new boolean[n + 1];
			for (int i = 0; i < v.length; i++) {
				p[i] = i;
				sz[i] = 1;
				q[i] = new TreeSet<>();
				q[i].add(v[i]);
			}
		}

		public int get(int x) {
			while (x != p[x]) {
				x = p[x];
			}
			return x;
		}

		public boolean unite(int a, int b) {
			int pa = get(a);
			int pb = get(b);
			if (pa == pb) {
				less.add(-1);
				more.add(-1);
				return false;
			}
			if (sz[pa] < sz[pb]) {
				p[pa] = pb;
				sz[pb] += sz[pa];

				less.add(pa);
				more.add(pb);
				for (int i : q[pa]) {
					q[pb].add(i);
				}
			} else {
				p[pb] = pa;
				sz[pa] += sz[pb];

				less.add(pb);
				more.add(pa);
				for (int i : q[pb]) {
					q[pa].add(i);
				}
			}
			return true;
		}

		public void popEdge() {
			int pa = less.pop();
			int pb = more.pop();
			if (pa < 0) {
				return;
			}
			for (int i : q[pa]) {
				q[pb].remove(i);
			}
			p[pa] = pa;
			sz[pb] -= sz[pa];
		}

		public int poll(int x) {
			int px = get(x);
			while (!q[px].isEmpty()) {
				int v = q[px].pollLast();
				if (!used[v]) {
					used[v] = true;
					return v;
				}
			}
			return 0;
		}

	}

	public void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		int q = in.nextInt();
		int[] v = new int[n];
		for (int i = 0; i < v.length; i++) {
			v[i] = in.nextInt();
		}
		int[] a = new int[m];
		int[] b = new int[m];
		for (int i = 0; i < b.length; i++) {
			a[i] = in.nextInt() - 1;
			b[i] = in.nextInt() - 1;
		}
		boolean[] type = new boolean[q];
		int[] x = new int[q];
		boolean[] removed = new boolean[m];
		for (int i = 0; i < q; i++) {
			if (in.nextInt() == 1) {
				x[i] = in.nextInt() - 1;
				type[i] = true;
			} else {
				x[i] = in.nextInt() - 1;
				removed[x[i]] = true;
			}
		}
		DSU1 dsu = new DSU1(v, m);
		for (int i = 0; i < removed.length; i++) {
			if (!removed[i]) {
				dsu.unite(a[i], b[i]);
			}
		}
		for (int i = q - 1; i >= 0; i--) {
			if (!type[i]) {
				dsu.unite(a[x[i]], b[x[i]]);
			}
		}
		for (int i = 0; i < q; i++) {
			if (type[i]) {
				out.println(dsu.poll(x[i]));
			} else {
				dsu.popEdge();
			}
		}
	}

	public void add(HashMap<Integer, Integer> map, int x) {
		if (map.containsKey(x)) {
			map.put(x, map.get(x) + 1);
		} else {
			map.put(x, 1);
		}
	}

	public void run() {
		try {
			if (systemIO) {
				in = new FastScanner(System.in);
				out = new PrintWriter(System.out);
			} else {
				in = new FastScanner(new File("input.txt"));
				out = new PrintWriter(new File("output.txt"));
			}
			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

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

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

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

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

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

	}

	// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
	public static void main(String[] arg) {
		new E().run();
	}
}


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

public class AmrandPins {

	public static void main(String[] args) throws IOException, FileNotFoundException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader in = new BufferedReader(new FileReader("AmrandPins"));

		StringTokenizer st = new StringTokenizer(in.readLine());
		int n = Integer.parseInt(st.nextToken());
		int x = Integer.parseInt(st.nextToken());
		int y = Integer.parseInt(st.nextToken());
		int xx = Integer.parseInt(st.nextToken());
		int yy = Integer.parseInt(st.nextToken());

		double dist = Math.sqrt((xx-x)*(xx-x) + (yy-y)*(yy-y));
		dist /= (double)(2*n);
		System.out.println((int)(Math.ceil(dist)));

	}

}


package B;

import java.util.Scanner;

public class _888B_BuggyRobot {
    public static void main(String args[]){
        Scanner sc= new Scanner(System.in);
        int n = sc.nextInt(),max=0,x=0,y=0;
        String ch = sc.next();
        char h;
        for(int i=0;i<n;i++){
            h = ch.charAt(i);
            switch (h) {
                case 'L':
                    x--;
                    break;
                case 'U':
                    y++;
                    break;
                case 'D':
                    y--;
                    break;
                case 'R':
                    x++;
                    break;
                default:break;
            }
            if(x==0 && y==0){
                max = i+1;
            }
        }
        System.out.println(max);
    }
}


import java.util.*;
public class MagicForest {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long count = 0;
		boolean[][][] visited = new boolean[n+1][n+1][n+1];
		for(int i = 1; i <= n; i++) {
			for(int j = i; j <= n; j++) {
				int k = i^j;
//				System.out.println("("+i+","+j+") = "+ k);
				if(k <= n && k >= 1 && !visited[i][j][k] && !visited[j][i][k] &&
						!visited[i][k][j] && !visited[j][k][i] && !visited[k][i][j] && !visited[k][j][i])
					if((i+j) > k && (i+k)>j && (j+k)>i)		{
						visited[i][j][k] = true;
						visited[j][i][k] = true;
						visited[i][k][j] = true;
						visited[j][k][i] = true;
						visited[k][i][j] = true;
						visited[k][j][i] = true;
						count++;
					}
//				}
			}
		}
		System.out.println(count);
	}
}


import java.util.Scanner;

	public class CloningToys {

		public static void main(String[] args) {
			// TODO Auto-generated method stub

			Scanner in= new Scanner(System.in);

			long a=in.nextLong();
			long b=in.nextLong();

			if(b>0) {

				if(Math.abs(a-b)%2==0 || (b>1 && a==0) || b-a>1 || (a>1 && b==1)) {
					System.out.println("No");
				}
				else {
					System.out.println("Yes");
				}

			}
			else {
				System.out.println("No");
			}

		}

	}


import java.io.*;
import java.util.*;
public class Lo
{

    public static void main(String args[] ) throws Exception
    {
        FastReader in = new FastReader();
        int n = in.nextInt();
        int m = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        int min1=Integer.MAX_VALUE;
        int min2=Integer.MAX_VALUE;
        for(int i=0;i<n;i++)
        {
            a[i] = in.nextInt();
            if(a[i]<min1)
            {
                min1 = a[i];
            }

        }
        for(int i=0;i<m;i++)
        {
            b[i] = in.nextInt();
            if(b[i]<min2)
            {
                min2 = b[i];
            }
        }

        if(min1==min2)
        {
            System.out.println(min1);
        }
        else if(min1<min2)
        {
            System.out.print(min1+""+min2);
        }
        else if(min1>min2)
        {
            System.out.print(min2+""+min1);
        }

    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

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


package com.javarush.test.level19.lesson10.bonus03;

import java.util.Scanner;

public class SolutionA {
    public static void main(String[] args) {
        int pixelNumber = new Scanner(System.in).nextInt();

        int[] dividers = new int[10000];
        int counter = 0;
        for (int i = 1; i < pixelNumber / 2 + 1; i++) {
            if (pixelNumber % i == 0) {
                dividers[counter] = i;
                counter++;
            }
        }

        dividers[counter] = pixelNumber;
        counter++;

        int minDifference = 1000000;
        int rows = 0;
        int columns = 0;
        for (int i = 0; i < counter; i++) {
            if (Math.abs(dividers[i] - dividers[--counter]) < minDifference) {
                rows = dividers[i];
                columns = dividers[counter];
                minDifference = Math.abs(rows - columns);
            }
        }
        if (rows > columns) {
            int temp = rows;
            rows = columns;
            columns = rows;
        }
        System.out.println(rows + " " + columns);
    }
}


package USACO;

public class ViciousKeyboard {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}


import java.util.*;
public class MakingString {

	public static void main(String[] args) {
		Scanner input = new Scanner (System.in);
		int n = input.nextInt();
		int a[] = new int[n+1];
		long ans = 0;
		boolean flag[] = new boolean[(int) 1e9 +1];
		for (int i = 1 ; i <= n ; ++i){
			a[i] = input.nextInt();
		}
		Arrays.sort(a);
//		for (int i = 0 ; i <= n ; ++i){
//			System.out.print(a[i] + " ");
//		}
		//soudi!
		int cnt = 0;
		for (int i = 1 ; i <= n ; ++i){
			if (!flag[a[i]]){
				ans += a[i];
				flag[a[i]] = true;
			//	System.out.println(a[i]);
			}
			else {
				cnt = 0;
				while (flag[a[i] - cnt] && a[i] - cnt > 0){
					++cnt;
				}
				ans += a[i] - cnt;
			//	System.out.println(a[i] - cnt);
				flag[a[i] - cnt] = true;
			}
//			if (a[i] != a[i-1] && !flag[a[i]]){
//				ans += a[i];
//				cnt = 0;
//				flag[a[i]] = true;
//				continue;
//			}
//			if (a[i] != a[i-1] && flag[a[i] - cnt]);
//			if (a[i] == a[i-1]) {
//				++cnt;
//				if (a[i] - cnt > 0 && !flag[a[i] - cnt]){
//					ans += a[i] - cnt;
//					flag [a[i] - cnt] = true;
//					continue;
//				}
//				if (a[i] - cnt > 0 && flag[a[i] - cnt]){
//					++cnt;
//					ans += a[i] - cnt;
//					flag[a[i] - cnt] = true;
//					continue;
//				}
//			}
		}
		System.out.println(ans);
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @author shakhawat.hossain
 * @since 2/4/2016 11:23 PM
 */
public class B624 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.readLine();

        boolean[] taken = new boolean[1000000000];

        String[] input = br.readLine().split(" ");
        int maxAllowedOccurances[] = new int[input.length];

        for (int i = 0; i < input.length; i++) {
            maxAllowedOccurances[i] = Integer.parseInt(input[i]);
        }

        Arrays.sort(maxAllowedOccurances);

        int maxStringLength = 0;

        for (int maxAllowedOccurance : maxAllowedOccurances) {
            int selectedFreq = maxAllowedOccurance;

            if (taken[selectedFreq]) {
                while (true) {
                    selectedFreq -= 1;

                    if (!taken[selectedFreq] || selectedFreq == 0) {
                        break;
                    }
                }
            }

            taken[selectedFreq] = true;

            maxStringLength += selectedFreq;
        }

        System.out.println(maxStringLength);
    }
}


import java.util.Scanner;

public class Solution {

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

        int n = scan.nextInt();
        String turn = "Mahmoud";

        if (n==1) {
            System.out.println("Ehab");
            return;
        }

        if (n==2) {
            System.out.println("Mahmoud");
        }

        while (n >= 0) {

            if (turn.equals("Mahmoud")) {
                int a = scan.nextInt();
                if (n - a >= 0 && a % 2 == 0) {
                    turn = "Ehab";
                    n = n - a;
                } else {
                    System.out.println("Ehab");
                    return;
                }
            }

            else if (turn.equals("Ehab")) {
                int a = scan.nextInt();
                if (n - a >= 0 && a % 2 != 0) {
                    turn = "Mahmoud";
                    n = n - a;
                } else {
                    System.out.println("Mahmoud");
                    return;
                }
            }
        }
    }
}


package today;

import java.util.Scanner;
public class sp {

	public static void main(String[] args) {
	Scanner input=new Scanner(System.in);
	int n;
	n=input.nextInt();
	if(n%2==0) {
		System.out.println("Mahmoud");

	}
	else {
		System.out.println("Ehab");
	}
	}
}


import java.util.*;
public class VasyaTheHipster {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();int diffsocks=0,extra=0;
if(a<b) {
	diffsocks=a;
	if(b-a)
	extra=(b-a)/2;}
else if(b<a) {
	diffsocks=b;extra=(a-b)/2;}
System.out.println(diffsocks+" "+extra);

	}

}


import java.util.*;

public class Watermelon {

    public static void main (String []args) {
    Scanner sc = new Scanner (System.in);
    int n = sc.nextInt ();
    int x = 1;
    int y = n-1;
    String sign = "NO";
   if (n%2 != 0){
   	while ( x!=n/2 ){
    	if ( x%2 == 0&& y%2 == 0 && x/2 >= 1 && y/2 >= 1)
    		sign = "YES";
    		x++;
    		y--;

    }
   }
   else {

    while  (x <= y){
    	if ( x%2 == 0&& y%2 == 0 && x/2 >= 1 && y/2 >= 1)
    		sign = "YES";
    		x++;
    		y--;

    }
   }
    System.out.print (sign);
    }

}


import java.util.Scanner;
public class MainActivity1 {
	public static void main(String[] args) {
	       Scanner sc = new Scanner(System.in);
	       String ch = sc.next();
	       String str = sc.next();
	       int f = 0, s = 0;

	       if(str.charAt(0) == 'F') {f = 1;}
	       if(str.charAt(0) == 'S') {s = 1;}

	       for(int i = 0; i < str.length() - 1; i++) {
				if(str.charAt(i) == 'F' && str.charAt(i + 1) == 'S') {
					f++;
				}
				if(str.charAt(i) == 'S' && str.charAt(i + 1) == 'F') {
					s++;
				}
			}

	       if(str.charAt(str.length()) == 'F') {f++;}
	       if(str.charAt(str.length()) == 'S') {s++;}

	       if(s > f) {
	    	   System.out.print("YES");
	       }
	       if(s < f) {
	    	   System.out.print("NO");
	       }
	       if(s == f) {
	    	   System.out.print("NO");
	       }
	}
}


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

public class Main {

	BufferedReader in;
	StringTokenizer str = null;
	PrintWriter out;

	private String next() throws Exception{
		while (str == null || !str.hasMoreElements())
			str = new StringTokenizer(in.readLine());
		return str.nextToken();
	}

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

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

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

	V []tree;
	int size = 0;

	int n, m, v;
	char []a, b, c;

	int [][][]dp;

	public void run() throws Exception{
		in =  new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		a = next().toCharArray();
		b = next().toCharArray();
		c = next().toCharArray();

		n = a.length;
		m = b.length;
		v = c.length;

		init();
		addString(c);

		for(int i = 0; i < size; ++i) getLink(i);
		// for(int i = 0; i < size; ++i) System.out.println(i + " " + tree[i]);

		dp = new int[n][m][v];
		for(int [][]i : dp)
			for(int []j : i)
				Arrays.fill(j, -1);
		int ret = dp(0, 0, 0);
		if (ret <= 0) {
			out.println(0);
		}else {
			print(0, 0, 0);
			out.println();
		}
		out.close();
	}

	final static int oo = Integer.MAX_VALUE / 2;

	private void print(int i, int j, int k) {
		if (i == n) return;
		if (j == m) return;

		if (a[i] == b[j]) {
			int c = a[i] - 'A';
			int next = go(k, c);
			if (next != v) {
				out.print(a[i]);
				print(i + 1, j + 1, next);
			}
		}else {
			int ret = dp(i + 1, j, k);
			if (ret < dp(i, j + 1, k)) {
				print(i, j + 1, k);
			}else {
				print(i + 1, j, k);
			}
		}
	}

	private int dp(int i, int j, int k) {
		if (k == v) return -oo;
		if (i == n) return 0;
		if (j == m) return 0;

		if (dp[i][j][k] != -1)
			return dp[i][j][k];

		int ret = -oo;
		if (a[i] == b[j]) {
			int c = a[i] - 'A';
			int next = go(k, c);
			if (next == v) ret = 0;
			ret = Math.max(ret, 1 + dp(i + 1, j + 1, next));
		}else {
			ret = Math.max(ret, dp(i, j + 1, k));
			ret = Math.max(ret, dp(i + 1, j, k));
		}
		return dp[i][j][k] = ret;
	}

	private void init() {
		tree = new V[110];
		tree[size++] = new V(-1, -1);
	}

	private void addString(char []a) {
		int v = 0;
		for(int i = 0; i < a.length; ++i) {
			int c = a[i] - 'A';
			if (tree[v].next[c] == -1) {
				tree[size] = new V(v, c);
				tree[v].next[c] = size++;
			}
			v = tree[v].next[c];
		}
		tree[v].leaf = true;
	}

	private int getLink(int v) {
		if (tree[v].link != -1) return tree[v].link;
		if (v == 0 || tree[v].p == 0) return tree[v].link = 0;
		return tree[v].link = go(getLink(tree[v].p), tree[v].pchar);
	}

	private int go(int v, int c) {
		if (tree[v].go[c] != -1) return tree[v].go[c];
		if (tree[v].next[c] != -1) return tree[v].go[c] = tree[v].next[c];
		if (v == 0) return tree[v].go[c] = 0;
		return tree[v].go[c] = go(getLink(v), c);
	}

	class V {
		int []next, go;
		int p, pchar;
		boolean leaf;
		int link;

		public V(int p, int pchar) {
			this.p = p;
			this.pchar = pchar;
			link = -1;
			leaf = false;
			next = new int[26];
			go = new int[26];
			Arrays.fill(next, -1);
			Arrays.fill(go, -1);
		}

		public String toString() {
			return "[ parent=" + p + " pchar=" + pchar + " link=" + link + " ]";
		}
	}

	public static void main(String[] args) throws Exception{
		new Main().run();
	}
}


public class Ogurechik {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int numberofpressedpanels = in.nextInt();
        in.nextLine();

        int[] array = new int[9];
        String answer = "YES";
        for (int i = 0; i < 4; i++) {
            String strochka = in.nextLine();
            for (char element : strochka.toCharArray()) {
                if (element != '.') {
                    array[element-'1']++;
                }
            }
        }
        for (int i = 0; i < array.length; i++) {
            if (array[i] > numberofpressedpanels * 2) {
                System.out.println("NO");
                break;
            }
            else{
                System.out.println("YES");
            }

        }

    }
}


	import java.util.Scanner;
/**
 *
 * @author dell
 */
public class CollectingBeatsIsFun {

	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		sc.nextLine();
		int[] t = new int[9];
		String s;
		for(int i = 0; i < 4; i++){
			s = sc.nextLine();
			for(int j = 0; j < 4; j++){
				if(s.charAt(j) == '.'){
					continue;
				}
				else{
					t[s.charAt(j)-'1']++;
				}
			}
		}
		boolean sol = true;
		for(int i = 0; i < 9; i++){
			if(t[i]>2*k){
				sol = false;
			}
		}
		if(sol){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
	}
}

}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
    ArrayList<String> v = new ArrayList<String>();
    long N = 0;

    void solve() throws IOException {
        long n = sl(), k = sl();
        N = n;
        ArrayList<Integer> pipes = new ArrayList<Integer>();
        for (int i = 1; i <= k; i++) {
            pipes.add(i);
        }
        dfs(pipes, 0, 0);
        System.out.println(found ? ans : -1);
    }

    boolean found = false;
    long ans = Long.MAX_VALUE - 1;

    void dfs(ArrayList<Integer> pipes, long pcount, long o) {
        if (o >= N) {
            if (o == N) {
                ans = Math.min(ans, pcount);
                found = true;
            }
            return;
        } else {
            for (int i = 0; i < pipes.size(); i++) {
                ArrayList<Integer> t = (ArrayList<Integer>) pipes.clone();
                Integer x = t.remove(i);
                dfs(t, pcount + 1, x + (pcount > 0 ? o - 1 : o));
            }
        }
    }

    public static void main(String[] Args) throws IOException {
        new B().solve();
    }

    static int[] dx_ = { 0, 0, 1, -1 };
    static int[] dy_ = { 1, -1, 0, 0 };

    // ----------------------- Library ------------------------

    // ----------------------- GRAPH ------------------------

    /**
     * important for speed!!! PrintWriter out=new PrintWriter(new
     * OutputStreamWriter(System.out)); out.print(...); out.close();
     *
     * @param v
     */
    // leap year is 29
    int[] year = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

    void initSystem() throws IOException {
        if (br != null)
            br.close();
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    void initFile() throws IOException {
        if (br != null)
            br.close();
        br = new BufferedReader(new InputStreamReader(new FileInputStream(
                "input.txt")));
    }

    void printWriter() {
        try {
            PrintWriter pr = new PrintWriter("output.txt");
            pr.println("hello world");
            pr.close();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    void comparator() {
        Point[] v = new Point[10];
        Arrays.sort(v, new Comparator<Point>() {
            @Override
            public int compare(Point a, Point b) {
                if (a.x != b.x)
                    return -(a.x - b.x);
                return a.y - b.y;
            }
        });
    }

    double distance(Point a, Point b) {
        double dx = a.x - b.x, dy = a.y - b.y;
        return Math.sqrt(dx * dx + dy * dy);
    }

    Scanner in = new Scanner(System.in);

    String ss() {
        return in.next();
    }

    char[] sc() {
        return in.next().toCharArray();
    }

    String sline() {
        return in.nextLine();
    }

    int si() {
        return in.nextInt();
    }

    long sl() {
        return in.nextLong();
    }

    int[] sai(int n) {
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = in.nextInt();
        }
        return a;
    }

    int[] si(int n) {
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = in.nextInt();
        }
        return a;
    }

    String[] ss(int n) {
        String[] a = new String[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = ss();
        }
        return a;
    }

    int[] sai_(int n) {
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = in.nextInt();
        }
        return a;
    }

    BufferedReader br;
    StringTokenizer tokenizer;
    {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    void tok() throws IOException {
        tokenizer = new StringTokenizer(br.readLine());
    }

    int toki() throws IOException {

        return Integer.parseInt(tokenizer.nextToken());
    }

    int[] rint(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++)
            a[i] = Integer.parseInt(tokenizer.nextToken());

        return a;
    }

    int[] rint_(int n) throws IOException {
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++)
            a[i] = Integer.parseInt(tokenizer.nextToken());

        return a;
    }

    String[] rstrlines(int n) throws IOException {
        String[] a = new String[n];
        for (int i = 0; i < n; i++) {
            a[i] = br.readLine();
        }
        return a;
    }

    long tokl() {
        return Long.parseLong(tokenizer.nextToken());
    }

    double tokd() {
        return Double.parseDouble(tokenizer.nextToken());
    }

    String toks() {
        return tokenizer.nextToken();
    }

    String rline() throws IOException {
        return br.readLine();
    }

    List<Integer> toList(int[] a) {
        List<Integer> v = new ArrayList<Integer>();
        for (int i : a)
            v.add(i);
        return v;
    }

    static void pai(int[] a) {
        System.out.println(Arrays.toString(a));
    }

    static int toi(Object s) {
        return Integer.parseInt(s.toString());
    }

    static int[] dx3 = { 1, -1, 0, 0, 0, 0 };
    static int[] dy3 = { 0, 0, 1, -1, 0, 0 };
    static int[] dz3 = { 0, 0, 0, 0, 1, -1 };

    static int[] dx = { 1, 0, -1, 1, -1, 1, 0, -1 }, dy = { 1, 1, 1, 0, 0, -1,
            -1, -1 };

    static int INF = 2147483647; // =2^31-1 // -8
    static long LINF = 922337203854775807L; // -8
    static short SINF = 32767; // -32768

    // finds GCD of a and b using Euclidian algorithm
    public int GCD(int a, int b) {
        if (b == 0)
            return a;
        return GCD(b, a % b);
    }

    static List<String> toList(String[] a) {
        return Arrays.asList(a);
    }

    static String[] toArray(List<String> a) {
        String[] o = new String[a.size()];
        a.toArray(o);
        return o;
    }

    static int[] pair(int... a) {
        return a;
    }
}


import java.util.Scanner;

public class DrazilandFactorial {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();

		String aTemp = input.next();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = Character.getNumericValue(aTemp.charAt(i));

		int sum = 1;
		for (int i = 0; i < aTemp.length(); i++)
			sum *= factor(a[i]);
		// System.out.println(sum);

		String Result = "";
		while (sum % 7 == 0) {

			sum /= 5040;
			Result += "7";

		}
		while (sum % 5 == 0) {
			sum /= 120;
			Result += "5";
		}
		while (sum % 3 == 0) {
			sum /= 6;
			Result += "3";
		}
		while (sum % 2 == 0) {
			sum /= 2;
			Result += "2";
		}
		System.out.println(Result);
	}

	public static int factor(int n) {
		int result = 1;
		for (int i = 1; i <= n; i++)
			result *= i;
		return result;
	}
}


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

/**
 *
 * @author PANKAJ
 */
public class bricks {
    public static int gcd(int x,int y){
    if(x>=y){
        if(x%y==0){
        return y;
    }
        else{
        return gcd(y,x%y);
        }
    }
    else{
       if(y%x==0){
       return x;
       }
       else{
       return gcd(x,y%x);
       }

    }
    };
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str= br.readLine();
        String a[]= str.split(" ");
        int arr[]= new int[4];
        for(int i=0;i<4;i++){
        arr[i]= Integer.parseInt(a[i]);
        }
        int f= gcd(arr[0],arr[1]);
        int g= arr[0]*arr[1]/f;
        int s= (arr[2]-1)/g;
        int t= arr[3]/g;
        System.out.println(t-s);
    }


import java.util.Scanner;
public class Melancia {
    public static void main(String[] args) {
       Scanner entrada = new Scanner(System.in);
       int melancia;
       melancia = entrada.nextInt();
       for( ;melancia<100 && melancia>1;){
          if(melancia%2==0){
             System.out.println("YES");
          }
       }
    }
}

// 1505572683048


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

public class M {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long x = Long.parseLong(br.readLine());
		x = -x;

		long y = Math.abs(x);

		int z = (int) ((y % 360) * (long) Math.signum(x));

		int min = (int) Math.min(Math.abs(z), Math.abs(360 - z));
		int best = 0;

		for (int i = 1; i < 4; i++) {
			z = (z + 90 + 360) % 360;
			int m = (int) Math.min(Math.abs(z), Math.abs(360 - z));
			if (m < min) {
				best = i;
				min = m;
			}
		}
		System.out.println(best);

	}

}


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

public class Balls {

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

        MyScanner in = new MyScanner();

        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int[] b = new int [n];
        int sum=0,max=0,buf=0;
        for (int i = 0; i < n; i++) {
            b[i] = in.nextInt();
        }
        for (int i = 0; i < n-1; i++) {
            if (b[i]==k && b[i+1]==k) {
                sum+=2;
            }
            if (i-1>0 && i+2<b.length) {
                int x=i-1;
                int y=i+2;

                if (b[x]==b[y]) {
                    while (true) {
                        if (x-1>=0 && b[x-1]==b[y]) {
                            buf++;
                            x--;
                        }
                        if (y+1<b.length && b[y+1]==b[x]) {
                            buf++;
                            y++;
                        }
                        if (buf==0 || (x==0 && y==b.length-1)) break;
                    }
                }

            }
            if (buf>0) sum += buf+2;
            max = Math.max(max,sum);
            sum=0;
            buf=0;
        }

        System.out.println(max);

    }

    public static class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    public MyScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

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

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

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

}

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;

/**
 *
 * @author User
 */
public class TestingCode {

    /**
     * @param args the command line arguments
     */
    static public Set<String> list = new HashSet<String>();
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter pr = new PrintWriter(System.out);

        int n = in.nextInt();

        for (int i = 1; i <= n; i++) {
             CalculateLucky("",i);
        }
        System.out.println(list.size());

}
    public static void CalculateLucky(String lucky , int n )
    {
        if(lucky.length()>n)
            return ;
        if(!lucky.equals(""))
        list.add(lucky);
        CalculateLucky(lucky+"8", n);
        CalculateLucky(lucky+"7", n);

    }
 }


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package codeforces;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;

/**
 *
 * @author ADNAN
 */
public class AgainTwentyFive {

    public static void main(String args[]) {
        int n;
        InputStreamReader ir = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(ir);
        PrintWriter pr = new PrintWriter(System.out);
        String line;
        String[] arr;
        try {

            line = br.readLine();

            n = Integer.parseInt(line);

            System.out.println(rec(new StringBuilder(""), n));

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static int rec(StringBuilder sb, int n) {

        if (sb.length() >= n) {
            return 0;
        }

        return 2 + rec(new StringBuilder(sb + "7"), n) + rec(new StringBuilder(sb + "8"), n);

    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.math.BigInteger;

public class C630 {

	public static void main(String[] args) throws IOException {
		BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter out= new BufferedWriter(new OutputStreamWriter(System.out));
		int n;
		int sum = 0;
		n = Integer.valueOf(in.readLine());
		BigInteger i ;
		for(i= new BigInteger("7");i.toString().length()<=n;i = i.add(new BigInteger("1")))
		{

			//System.out.print("1");
			if(i.toString().contains("0")||i.toString().contains("1")||i.toString().contains("2")||i.toString().contains("3")||i.toString().contains("4")||i.toString().contains("5")||i.toString().contains("6")||i.toString().contains("9"))
			{
				continue;
			}
			else
			{
				sum++;
			}
		}
		out.write(String.valueOf(sum));
		out.flush();
		out.close();
	}

}


import java.util.Scanner;

public class C {
	public static void main(String[] args) {
		Scanner sc= new Scanner (System.in);
		int n= sc.nextInt();
		long result=0L;
		for(int i=1; i<=n; i++)
		result+= (Math.pow(2, i));
		System.out.println((long)result);
	}

}