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

public class tr0 {
	static PrintWriter out;
	static StringBuilder sb;
	static final double EPS = 1e-9;
	static long mod = 1000000007;
	static int inf = (int) 1e9 + 2;
	static long[] fac;
	static int[] si;
	static ArrayList<Integer> primes;
	static ArrayList<Integer>[] ad;
	static int[] a;
	static long [][]memo;
	static int m, k,n;
	static HashMap<Integer, Integer> t;
	static boolean f;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		a=new int [3];
		n=sc.nextInt();
		memo=new long [n+1][3];
		int l=sc.nextInt();
		int r=sc.nextInt();
		for(long []h:memo)
			Arrays.fill(h, -1);
		a[0]=r/3-(l-1)/3;
		a[1]=(r+2)/3-(l-1+2)/3;
		a[2]=(r+1)/3-(l-1+1)/3;
	//	System.out.println(Arrays.toString(a));
		int z=0;
		int o=0;
		int t=0;
		for(int i=9;i<=99;i++)
			if(i%3==0)
				z++;
			else if(i%3==1)
				o++;
			else
				t++;
		out.println(dp(0,0)%mod);
		out.close();
	}
	static long dp(int i,int st) {
		if(i==n && st==0)
			return 1;
		if(i==n && st!=0)
			return 0;
		if(memo[i][st]!=-1)
			return memo[i][st];
		long ans=0;
		if(a[0]>0)
			ans+=((dp(i+1,st))*a[0])%mod;
		if(a[1]>0)
			ans+=(dp(i+1,(st+1)%3)*a[1])%mod;
		if(a[2]>0)
			ans+=(dp(i+1,(st+2)%3)*a[2])%mod;
		return memo[i][st]=ans%mod;
	}
    static long getval(long x) {
    	if(x==0)
    		return 0l;
    	if(x==1)
    		return 1;
    	long k=0;
    	int id=0;
        for(long i=0;i<=60;i++) {
        	if(x>=(1l<<i)) {
        	    x-=(1l<<i);
        	   id++;
        	}
        	else
        		break;
        }
        long odd=0;
        long even=0;
        if((id)%2==0) {
            int id1=0;
            while(id1<(id)) {
            	odd+=(1l<<id1);
            	id1+=2;
            }
            id1=1;
            while(id1<(id)) {
            	even+=(1l<<id1);
            	id1+=2;
            }
            odd+=x;
        }
        else {
        	//System.out.println("a7a");
        	int id1=1;
            while(id1<(id)) {
            	even+=(1l<<id1);
            	id1+=2;
            }
            id1=0;
            while(id1<(id)) {
            	odd+=(1l<<id1);
            	id1+=2;
            }
            even+=x;
        }
        even=((even)%mod)*((even+1)%mod);
        odd=(odd%mod)*(odd%mod);
    	return (even+odd)%mod;
    }
	static class seg implements Comparable<seg> {
		char a;
		int b;
		seg(char s, int e) {
			a= s;
			b= e;
		}
		public String toString() {
			return a+" "+b;
		}
		public int compareTo(seg o) {
		    return o.b-b;
		}
	}

	static public class SegmentTree { // 1-based DS, OOP

		int N; // the number of elements in the array as a power of 2 (i.e. after padding)
		int[] array, sTree, lazy, candies;

		SegmentTree(int[] in) {
			array = in.clone();
			N = in.length - 1;
			sTree = new int[N << 1]; // no. of nodes = 2*N - 1, we add one to cross out index zero
			lazy = new int[N << 1];
			candies = new int[N << 1];
			build(1, 1, N);
			build2(1, 1, N);
		}

		public String toString() {
			return Arrays.toString(sTree) + "\n" + Arrays.toString(candies);
		}

		void build(int node, int b, int e) // O(n)
		{
			if (b == e)
				sTree[node] = array[b];
			else {
				int mid = b + e >> 1;
				build(node << 1, b, mid);
				build(node << 1 | 1, mid + 1, e);
				sTree[node] = (sTree[node << 1] + sTree[node << 1 | 1]) % 10;
				if (sTree[node << 1] + sTree[node << 1 | 1] >= 10)
					candies[node]++;
			}
		}

		void build2(int node, int b, int e) // O(n)
		{
			if (b == e)
				b = e;
			else {
				int mid = b + e >> 1;
				build(node << 1, b, mid);
				build(node << 1 | 1, mid + 1, e);
				candies[node] = (candies[node << 1] + candies[node << 1 | 1]);
			}
		}

		void update_point(int index, int val) // O(log n)
		{
			index += N - 1;
			sTree[index] += val;
			while (index > 1) {
				index >>= 1;
				sTree[index] = sTree[index << 1] + sTree[index << 1 | 1];
			}
		}

		void update_range(int i, int j, int val) // O(log n)
		{
			update_range(1, 1, N, i, j, val);
		}

		void update_range(int node, int b, int e, int i, int j, int val) {
			if (i > e || j < b)
				return;
			if (b >= i && e <= j) {
				sTree[node] += (e - b + 1) * val;
				lazy[node] += val;
			} else {
				int mid = b + e >> 1;
				propagate(node, b, mid, e);
				update_range(node << 1, b, mid, i, j, val);
				update_range(node << 1 | 1, mid + 1, e, i, j, val);
				sTree[node] = sTree[node << 1] + sTree[node << 1 | 1];
			}

		}

		void propagate(int node, int b, int mid, int e) {
			lazy[node << 1] += lazy[node];
			lazy[node << 1 | 1] += lazy[node];
			sTree[node << 1] += (mid - b + 1) * lazy[node];
			sTree[node << 1 | 1] += (e - mid) * lazy[node];
			lazy[node] = 0;
		}

		// static int c=0;
		int query(int i, int j) {
			// c=0;
			return query(1, 1, N, i, j);
		}

		int query(int node, int b, int e, int i, int j) // O(log n)
		{
			if (i > e || j < b)
				return 0;
			if (b >= i && e <= j)
				return candies[node];
			int mid = b + e >> 1;
			// propagate(node, b, mid, e);
			int q1 = query(node << 1, b, mid, i, j);
			int q2 = query(node << 1 | 1, mid + 1, e, i, j);
			return q1 + q2;
		}
	}

	static int x, y, d;

	static long power(int i) {
		// if(i==0)
		// return 1;
		long a = 1;
		for (int k = 0; k < i; k++)
			a *= i;
		return a;
	}

	static void extendedEuclid(int a, int b) {
		if (b == 0) {
			x = 1;
			y = 0;
			d = a;
			return;
		}
		extendedEuclid(b, a % b);
		int x1 = y;
		int y1 = x - a / b * y;
		x = x1;
		y = y1;
	}

	static void dfs(int u) {
		int counter = 1;
		for (int v : ad[u])
			if (ans[v] == 0) {
				if (counter == ans[u]) {
					counter++;
					ans[v] = counter;
				} else
					ans[v] = counter++;
				if (counter > k)
					f = false;
				dfs(v);
			}
	}

	static void bfs(int s) {
		Queue<Integer> q = new LinkedList();
		q.add(s);
		ans[s] = 1;
		while (!q.isEmpty()) {
			int u = q.remove();
			int c = 1;
			for (int v : ad[u]) {
				if (ans[v] == 0) {
					// System.out.println(u);
					if (c == ans[u]) {
						c++;
						ans[v] = c++;
					} else
						ans[v] = c++;
					// System.out.println(v+" "+c);
					if (ans[v] > k)
						f = false;
					q.add(v);
				}
			}
		}
	}

	static void seive() {
		si = new int[1000001];
		primes = new ArrayList<>();
		int N = 1000001;
		si[1] = 1;
		for (int i = 2; i < N; i++) {
			if (si[i] == 0) {
				si[i] = i;
				primes.add(i);
			}
			for (int j = 0; j < primes.size() && primes.get(j) <= si[i] && (i * primes.get(j)) < N; j++)
				si[primes.get(j) * i] = primes.get(j);

		}
	}

	static long inver(long x) {
		int a = (int) x;
		long e = (mod - 2);
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1) {
				// System.out.println(res*a);
				res = (int) ((1l * res * a) % mod);
			}
			a = (int) ((1l * a * a) % mod);
			e >>= 1;
		}
		// out.println(res+" "+x);
		return res % mod;
	}

	static long fac(int n) {
		if (n == 0)
			return fac[n] = 1;
		if (n == 1)
			return fac[n] = 1;
		long ans = 1;
		for (int i = 1; i <= n; i++)
			fac[i] = ans = (i % mod * ans % mod) % mod;
		return ans % mod;
	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	static class unionfind {
		int[] p;
		int[] size;

		unionfind(int n) {
			p = new int[n];
			size = new int[n];

			for (int i = 0; i < n; i++) {
				p[i] = i;
			}
			Arrays.fill(size, 1);
		}

		int findSet(int v) {
			if (v == p[v])
				return v;
			return p[v] = findSet(p[v]);
		}

		boolean sameSet(int a, int b) {
			a = findSet(a);
			b = findSet(b);
			if (a == b)
				return true;
			return false;
		}

		int max() {
			int max = 0;
			for (int i = 0; i < size.length; i++)
				if (size[i] > max)
					max = size[i];
			return max;
		}

		void combine(int a, int b) {
			a = findSet(a);
			b = findSet(b);
			if (a == b)
				return;
			if (size[a] > size[b]) {
				p[b] = a;
				size[a] += size[b];

			} else {
				p[a] = b;
				size[b] += size[a];
			}
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
     public static void main(String []arg) throws FileNotFoundException{
    Scanner s=new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out) ;
            int u=s.nextInt();
            int v=s.nextInt();
            int t=s.nextInt()-2;
            int x=s.nextInt();
            int temp=0;
            if(u>v){temp=u;u=v;v=temp;}
            int ans=u+v;
            while(t>0){
                    if(u<=v){u=u+x;ans=ans+u;}
                    else{v=v+x;ans=ans+v;}
            t--;
                        }
            out.print(ans);
        out.flush();

out.close)(;
}
}


public class Cal {
    static Scanner input = new Scanner(System.in);
   static  int v1, v2, t, d;
    public static void main(String[] args) {

       v1=input.nextInt();
        v2=input.nextInt();
         t=input.nextInt();
          d=input.nextInt();

         int c=1;
       int total=0;
       if (v1==v2){
           System.out.println (v1*t);
       }

       total=v1;

      while (c<=t-2){

          // 7 , 12-10

          total =total+ Math.min(v1 + c*d, (v2+(t-1)*d) - c*d);

          c++;

      }
      total=total+v2;

      System.out.println(total);

    }

}


import java.util.Scanner;

public class B534 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int v1 = scan.nextInt();
        int v2 = scan.nextInt();
        int t = scan.nextInt();
        int d = scan.nextInt();
        int sum = v2 + v1, cal = v2;
        t-=2;
        for (int i = t; i>=1; i--){
            int v = v1 + d*i;
            if (Math.abs(v - cal)>d){
                cal = v -Math.abs((v - cal)-d);
                sum += cal;
            }
            else{
                sum+=v;
            }
        }
        System.out.println(sum);

    }


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

public class test
{
    public static void main(String args[]) throws IOException
    {
        InputStreamReader inp = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(inp);

        String s[] = br.readLine().split(" ");

        int v1 = Integer.parseInt(s[0]);
        int v2 = Integer.parseInt(s[1]);

        String s1[] = br.readLine().split(" ");

        int t = Integer.parseInt(s1[0]);
        int d = Integer.parseInt(s1[1]);
        int sum=0;
        while(t--)
        {
            if(v1<=v2)
            {
                sum+=v1;
                v1+=d;
            }
            else
            {
                sum+=v2;
                v2+=d;
            }
        }
        System.out.println(sum);

    }

}


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

public class C {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer stok;

    String nextToken() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            stok = new StringTokenizer(s);
        }
        return stok.nextToken();
    }

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

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

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

    char nextChar() throws IOException {
        return (char) (br.read());
    }

    String nextLine() throws IOException {
        return br.readLine();
    }
boolean same(int x1, int x2, int x3, int x4) {
    return (x1 == x2 && x2 == x3 && x3 == x4);
}
    private void solve() throws IOException {
        int[] a = new int[25];
        int n = 24;
        for (int i = 1; i <= 24; i++) {
            a[i] = nextInt();
        }

        boolean[] faceOk = new boolean[6];

        int cnt = 0;
        for (int i = 0; i < 6; i++) {
            faceOk[i] = same(a[i * 4 + 4],a[i * 4+1],a[i * 4+2],a[i * 4+3]);
            if (faceOk[i]) cnt++;
        }

        if (cnt == 6) {
            throw new IOException();
        }
        if (cnt != 2) {
            out.println("NO");
            return;
        }

        if (faceOk[0] != faceOk[2] || faceOk[1] != faceOk[5] || faceOk[3] != faceOk[4])
        {
            out.println("NO");
            return;
        }

        if (faceOk[0]) {
            if (same(a[5], a[6], a[19], a[20]) && same(a[17], a[18], a[23], a[24]) && same(a[21], a[22], a[15], a[16]) && same(a[13], a[14], a[7], a[8])) {
                out.println("YES");
                return;
            }
            if (same(a[5], a[6], a[15], a[16]) && same(a[13], a[14], a[23], a[24]) && same(a[21], a[22], a[19], a[20]) && same(a[17], a[18], a[7], a[8])) {
                out.println("YES");
                return;
            }
            out.println("NO");
            return;
        }

        if (faceOk[1]) {
            if (same(a[17], a[19], a[1], a[2]) && same(a[3], a[4], a[13], a[15]) && same(a[14], a[16], a[11], a[12]) && same(a[9], a[10], a[18], a[20])) {
                out.println("YES");
                return;
            }
            if (same(a[17], a[19], a[11], a[12]) && same(a[9], a[10], a[13], a[15]) && same(a[14], a[16], a[1], a[2]) && same(a[3], a[4], a[18], a[20])) {
                out.println("YES");
                return;
            }
            out.println("NO");
            return;
        }

        if (faceOk[3]) {
            if (same(a[1], a[3], a[6], a[8]) && same(a[5], a[7], a[10], a[12]) && same(a[9], a[11], a[21], a[23]) && same(a[22], a[24], a[2], a[4])) {
                out.println("YES");
                return;
            }
            if (same(a[1], a[3], a[21], a[23]) && same(a[22], a[24], a[10], a[12]) && same(a[9], a[11], a[6], a[8]) && same(a[5], a[7], a[2], a[4])) {
                out.println("YES");
                return;
            }
            out.println("NO");
            return;
        }

        throw new IOException();
    }

    void run() throws IOException {
        // br = new BufferedReader(new FileReader("input.txt"));
        // out = new PrintWriter("output.txt");
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        br.close();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        // Locale.setDefault(Locale.US);
        new C().run();
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

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

    static class C887 {
        private int sequences = new int[][]{
                {1, 3, 5, 7, 9, 11, 24, 22},
                {2, 4, 6, 8, 10, 12, 23, 21},
                {13, 14, 5, 6, 17, 18, 21, 22},
                {15, 16, 7, 8, 19, 20, 23, 24},
                {3, 4, 17, 19, 10, 9, 16, 14},
                {1, 2, 22, 24, 12, 11, 15, 13}
        };

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int cube[] = new int[25];
            for (int i = 1; i <= 24; i++) cube[i] = in.scanInt();
            for (int i = 0; i < 6; i++) {
                for (int k = 0; k < 2; k++) {
                    rotate(cube, sequences[i], k);
                    if (checkit(cube)) {
                        out.println("YES");
                        return;
                    }
                    rotate(cube, sequences[i], 1 ^ k);
                }
            }
            out.println("NO");
        }

        private void rotate(int[] cube, int[] seq, int state) {
            if (state == 1) {
                int temp1 = cube[seq[0]];
                int temp2 = cube[seq[1]];
                for (int i = 0; i < 6; i++) cube[seq[i]] = cube[seq[i + 2]];
                cube[seq[6]] = temp1;
                cube[seq[7]] = temp2;
            } else {
                int temp1 = cube[seq[6]];
                int temp2 = cube[seq[7]];
                for (int i = 7; i >= 2; i--) cube[seq[i]] = cube[seq[i - 2]];
                cube[seq[0]] = temp1;
                cube[seq[1]] = temp2;
            }
        }

        private boolean checkit(int cube[]) {
            for (int i = 1; i <= 24; i++) {
                if (cube[i] != cube[(((i / 4) - (i % 4 == 0 ? 1 : 0)) * 4) + 1]) return false;
            }
            return true;
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}


public class zher{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int s= in.next();
        if (s%==0) System.out.println(2);
        else System.out.println(1);
    }
}


import java.util.Scanner;

/**
 *
 * @author Nicolás Pérez Garay
 */
public class Main {

    /**
     *
     * @param args
     */
    public static void main(String[] args) {
       Scanner leer= new Scanner(System.in);
      int p=2,a=1;

        while(leer.hasNextInt()){
            int n=0;
            n= leer.nextInt();

            if (n>0){
                if(n%2!=0){
                    System.out.println(a);
                }
                else{
                    System.out.println(p);
                }
            }
            else{
            System.exit(0);
            }
        }
    }

// 1508912323750


public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        long l;
        Scanner sc=new Scanner(System.in);
        l=sc.nextInt();

        if(l%2!=0)System.out.println("1");
        else System.out.println("2");

    }

}


public class Solution {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println(scanner.nextInt() % 2 == 0 ? 2 : 1);
    }
}


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

public class Main {

	// split de array
	public static int[] atoi(String cad) {
		String read[] = cad.split(" ");
		int res[] = new int[read.length];
		for (int i = 0; i < read.length; i++) {
			res[i] = Integer.parseInt(read[i]);
		}
		return res;
	}

	// split de String
	public static String[] atos(String cad) {
		return cad.split(" ");
	}

	// parsing de String a int
	public static int parseo(String cad, int index) {
		return Integer.parseInt(cad.split(" ")[index]);
	}

	// memory status
	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory()
				- Runtime.getRuntime().freeMemory() >> 20)
				+ "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}

	// imprimir array
	static void printArrayInt(int[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				System.out.print(" ");
			System.out.print(array[i]);
		}
		System.out.println();
	}

	// impresion de datos
	static void print(Object... obj) {
		for (int i = 0; i < obj.length; i++) {
			if (i != 0)
				System.out.print(" ");
			System.out.print(obj[i]);
		}
		System.out.println();
	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine());
		ArrayList<Integer> lista=new ArrayList<>(500);
		lista.add(1);
		lista.add(3);
		for (int i = 3;((i*(i+1))/2)<=500 ; i++) {
			lista.add(((i*(i+1))/2));
		}
		if(lista.contains(n))System.out.println("YES");
		else System.out.println("NO");

	}
}


//import java.util.Scanner;

/*
 * 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.
 */

/**
 *
 * @author ASUS
 */
/*public class Pro3 {
    static int gcd(int x,int y){
        if(x==0)
            return y;
        if(y==0)
            return x;
        if(x>y)
            return gcd(x-y,y);
        return gcd(x,y-x);
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int temp1 = n;
        int temp2 = n-2;
        int sum=0;
        for(int i=2;i<n;i++){
            while(n>=i){
                int temp3 = n%i;
                n=n/i;
                sum+=temp3;
            }
            sum+=n;
            n=temp1;

        }
        int e=gcd(sum,temp2);
        System.out.println(sum/e + "/" + temp2/e);
    }

}*/
import java.util.Scanner;
public class Main {
    static boolean isTri(int num){
        if(num<0)
            return false;
        int sum=0;
        for(int i=1;sum<=num;i++){
            sum+=i;
            if(sum==num)
                return true;

        }
        return false;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        if(isTri(num)){
            System.out.println("YES");
        }
        else
            System.out.println("NO");

    }

}


import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.Arrays;
import java.util.concurrent.*;
import java.util.regex.*;

public class Solution
{
public static void main (String args[])throws IOException
{
Scanner in=new Scanner(System.in);
int n,t,t1;
t=in.nextInt();
n=Math.sqrt(1+(8*t));
n=(n-1)/2;
if(n*(n+1)/2==t)
System.out.println("YES");
else
System.out.println("NO");
}
}


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

/**
 *
 * @author xergioalex
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer token;
        String in= input.readLine();
        while(in != null){
            int n = Integer.valueOf(in);
            double root = n;
            root = Math.sqrt(8*n+1);
            n = (int) root;
            if(root == n){
                System.out.println("YES");
            }
            else{
                System.out.println("NO");
            }
            in= input.readLine();
        }

    }
}


public class Main{
    public static void main(String args[]){
        Scanner no=new Scanner(System.in);
         String m=no.next();
         String n=no.next();
         for(int i=0;i<m.length();i++){
            if(m.charAt(i)==m.charAt(i)){
                System.out.print("0");
            }
            else{
                System.out.print("1");
            }

         }
    }
}


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

public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in);
		String[] s1=in.readLine().split("");
		String[] s2=in.readLine().split("");
		String s3="";
		for(int i=0;i<s1.length;i++)
		{
			if(s1[i]==s2[i])
			{
				s3+=0;
			}
			else
			{
				s3+=1;
			}
		}
		System.out.println(s3);
	}
}


import java.util.*;
import java.math.*;
import java.lang.*;
import java.io.*;
public class Main{
  static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
  public static void main(String[] args) {
    Reader sc = new Reader();
    String s1 = sc.readLine();
    String s2 = sc.readLine();
    String s = "";
    for(int i = 0 ; i< s1.length() ; i++){
      if(s1.charAt(i) == s2.charAt(i)){
        s += 0;
      }
      else{
        s += 1;
      }
    }
    System.out.println(s);
  }
}


import java.util.*;
public class na
{
    public static void main(String ar[])
    {
        Scanner scan= new Scanner(System.in);
        String s1=scan.next();
        String s2=scan.next();
        for(int i=0;i<s1.length();i++)
        {
            System.out.println(Integer.parseInt(String.valueOf(s.charAt(i)))^Integer.parseInt(String.valueOf(s.charAt(i)));
        }
    }
}


import java.util.Scanner;
public class split{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			System.out.printf(n/2+1);
		}
	}
}


import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
static boolean prime(int n) {
	public static void main(String[] args) {
                 Scanner sc = new Scanner(System.in);
		    int n = sc.nextInt();
		    System.out.println(n/2+1);

}}


public class Splits {
public static void main (String args[]){
	Scanner number=new Scanner(System.in);
	   System.out.println("Enter your rollno");
	   int rollno=number.nextInt();
	   int n=(rollno/2+1);
	   System.out.println(" your rollno is " + n );

}
}


public class Codeforces964A {
    public static void main(String[] args) {
        // TODO code application logic here
        System.out.println("");
        Scanner input = new Scanner(System.in);
        int num = input.nextInt();
        int counter = 0;
        for(int i  = 1;i<=num;i++){
            if(i+i<=num){
               counter++;
            } else if (i==num){
                counter++;
            }
        }
        System.out.println(counter);
    }

}


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

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

    private void solve(Scanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        HashSet<Integer> hs = new HashSet<>();
        int aa==a;
        int bb=b;
        int cc=c;
        int ii=0; int jj=0; int kk=0;
        outer: for(int i=1; i<=1000; i++) {
            for(int j=1; j<=1000; j++) {
                if(i+j>1000) break;
                for(int k=1; k<=1000; k++) {
                    if(i+j+k>1000) break;
                    int aa==a;
                    int bb=b;
                    int cc=c;
                    if(i*j==aa) aa=-1;
                    else if(i*k==aa) aa=-1
                    else if(j*k==aa) aa=-1;

                    if(i*j==bb) bb=-1;
                    else if(i*k==bb) bb=-1
                    else if(j*k==bb) bb=-1;

                    if(i*j==cc) cc=-1;
                    else if(i*k==cc) cc=-1
                    else if(j*k==cc) cc=-1;
                    if(aa==-1 && bb==-1 && cc==-1) {
                        ii=i; jj=j; kk=k;
                        break outer;
                    }
                }
            }
        }
        out.println(ii*4 + jj*4 + kk*4);
    }
}


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

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

    private void solve(Scanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int ii=0; int jj=0; int kk=0;
        outer: for(int i=1; i<=1000; i++) {
            for(int j=1; j<=1000; j++) {
                if(i+j>1000) break;
                for(int k=1; k<=1000; k++) {
                    if(i+j+k>1000) break;
                    int aa=a;
                    int bb=b;
                    int cc=c;
                    if(i*j==aa) aa=-1;
                    else if(i*k==aa) aa=-1
                    else if(j*k==aa) aa=-1;

                    if(i*j==bb) bb=-1;
                    else if(i*k==bb) bb=-1
                    else if(j*k==bb) bb=-1;

                    if(i*j==cc) cc=-1;
                    else if(i*k==cc) cc=-1
                    else if(j*k==cc) cc=-1;
                    if(aa==-1 && bb==-1 && cc==-1) {
                        ii=i; jj=j; kk=k;
                        break outer;
                    }
                }
            }
        }
        out.println(ii*4 + jj*4 + kk*4);
    }
}


import java.util.*;
public class supercentral_points {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b=in.nextInt();
		int c=in.nextInt();
                int peri=0;
                int s[] = new int[6];
		int s[0] = (int)Math.sqrt(a);
                int s[1] = a/s[0];
                int s[2] = (int)Math.sqrt(b);
                int s[3]= b/s[2];
                int s[4] = (int)Math.sqrt(c);
                int s[5] = c/s[4];
                for(int i=0 ; i<6 ; i++)
                 peri=peri+s[i];
		System.out.println(peri*2);

	}

}


import java.util.Scanner;

public class java1 {
   public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long x =in.nextLong(), y = in.nextLong(), z = in.nextLong();
    long a = Math.sqrt(z*x/y);
    long b = Math.sqrt(x*y/z);
    long c = Math.sqrt(z*y/x);

    System.out.println(4*(a + b + c));
       }
}


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

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

    static class CGarland {
        int dp;

        public void solve(int testNumber, InputReader c, OutputWriter w) {
            int n = c.readInt();
            int a[] = c.readIntArray(n);
            int even = n / 2, odd = (n - 1) / 2 + 1;
            dp = new int[n][n][n];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    Arrays.fill(dp[i][j], -1);
                }
            }
            for (int i = 0; i < n; i++) {
                if (a[i] != 0) {
                    if (a[i] % 2 == 0) {
                        even--;
                    } else {
                        odd--;
                    }
                }
            }
            w.printLine(Math.min(solve_(0, a, 1, even, odd), solve_(0, a, 0, even, odd)));
        }

        private int solve_(int x, int[] a, int pre, int even, int odd) {

            if (x >= a.length) {
                return 0;
            }
            if (dp[x][even][odd] != -1) {
                return dp[x][even][odd];
            }

            int res = a.length;
            if (a[x] == 0) {
                if (even > 0) {
                    res = Math.min(res, solve_(x + 1, a, 1, even - 1, odd) + pre ^ 1);
                }
                if (odd > 0) {
                    res = Math.min(res, solve_(x + 1, a, 0, even, odd - 1) + pre);
                }
            } else {
                if (a[x] % 2 == 0) {
                    res = Math.min(res, solve_(x + 1, a, 1, even, odd) + pre ^ 1);
                } else {
                    res = Math.min(res, solve_(x + 1, a, 0, even, odd) + pre);
                }
            }
            dp[x][even][odd] = res;
            return res;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

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

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

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

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

    }

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

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

        public int[] readIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = readInt();
            }
            return array;
        }

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

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

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

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

        }

    }
}


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

public class r612c {
	static int[] a;
	static int[][][][] dp;
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		a=new int[n];
		int o=0,e=0;
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
			if(a[i]>0) {
				if(a[i]%2==1) o++;
				else e++;
			}
		}
		int ohave=n/2+n%2, ehave=n/2;
		int oleft=ohave-o, eleft=ehave-e;
		dp=new int[n][oleft+1][eleft+1][2];
		for(int[][][] d:dp) for(int[][] dd:d) for(int[] ddd:dd) Arrays.fill(ddd,-1);
		System.out.println(go(0,oleft,eleft,0));
	}
	public static int go(int at, int o, int e, int prev) {
	    if(at==a.length) return 0;
		if(dp[at][o][e][prev]!=-1) return dp[at][o][e][prev];
		int res=Integer.MAX_VALUE/2-5;

		if(a[at]!=0) {
			int add=0;

			if(at!=0) {
				if(prev!=a[at]%2) add++;
			}
			res=Math.min(res,add+go(at+1,o,e,a[at]%2));
		}
		else {
			int adde=0, addo=0;
			if(at!=0) {
				if(prev!=0) adde++;
			}
			if(at!=0) {
				if(prev!=1) addo++;
			}

			if(o>0) res=Math.min(res,addo+go(at+1,o-1,e,1));
			if(e>0) res=Math.min(res,adde+go(at+1,o,e-1,0));
		}
		return dp[at][o][e][prev]=res;
	}


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

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

    static class CGarland {
        static int totalOdd;
        static int totalEven;
        static int curSum;
        static int[] arr;
        static Integer[][][] memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            arr = new int[n];
            int even = 0, odd = 0;
            HashSet<Integer> set = new HashSet<>();
            for (int i = 1; i <= n; i++)
                set.add(i);
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
                set.remove(arr[i]);
            }
            for (int x : set) {
                odd += x % 2;
                even += (x % 2) ^ 1;
            }
            totalOdd = odd;
            totalEven = even;
            curSum = new int[n + 1];
            curSum[0] = arr[0] == 0 ? 1 : 0;
            for (int i = 1; i < n; i++)
                curSum[i] = curSum[i - 1] + (arr[i] == 0 ? 1 : 0);
            curSum[n] = curSum[n - 1];
            memo = new Integer[3][n][n + 1];
            pw.println(dp(0, -1, odd));
        }

        private int dp(int idx, int prev, int curOdd) {
            int curEven = totalEven - (curSum[idx] - (totalOdd - curOdd));
            if (curEven < 0 || curOdd < 0)
                return (int) 1e9;
            if (idx == arr.length)
                return 0;
            if (memo[prev + 1][idx][curOdd] != null)
                return memo[prev + 1][idx][curOdd];
            if (arr[idx] != 0) {
                int temp;
                if (prev == -1)
                    temp = dp(idx + 1, arr[idx] % 2, curOdd);
                temp = (arr[idx] + prev) % 2 + dp(idx + 1, arr[idx] % 2, curOdd);
                return memo[prev + 1][idx][curOdd] = temp;
            }
            int even = prev + dp(idx + 1, 0, curOdd);
            int odd = (prev + 1) % 2 + dp(idx + 1, 1, curOdd - 1);
            return memo[prev + 1][idx][curOdd] = Math.min(even, odd);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

    }
}


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

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

    static class CGarland {
        static int sum;
        static int[] arr;
        static Integer memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            arr = new int[n];
            int even = 0, odd = 0;
            HashSet<Integer> set = new HashSet<>();
            for (int i = 1; i <= n; i++)
                set.add(i);
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
                set.remove(arr[i]);
            }
            for (int x : set) {
                odd += x % 2;
                even += (x % 2) ^ 1;
            }
            sum = even + odd;
            memo = new Integer[3][n][n];
            pw.println(dp(0, -1, odd));
        }

        private int dp(int idx, int prev, int curOdd) {
            if (idx == arr.length)
                return 0;
            int curEven = sum - curOdd;
            if (curEven < 0 || curOdd < 0)
                return (int) 1e9;
            if (memo[prev + 1][idx][curOdd] != null)
                return memo[prev + 1][idx][curOdd];
            if (arr[idx] != 0) {
                if (prev == -1)
                    return dp(idx + 1, arr[idx] % 2, curOdd);
                int even = arr[idx] % 2 + dp(idx + 1, arr[idx] % 2, curOdd);
                int odd = (1 + arr[idx] % 2) + dp(idx + 1, arr[idx] % 2, curOdd - 1);
                return memo[prev + 1][idx][curOdd] = Math.min(even, odd);
            }
            return memo[prev + 1][idx][curOdd] = dp(idx + 1, arr[idx] % 2, curOdd);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

    }
}


public class Codechef {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for (int j = 0; j < t; j++) {
            int key = sc.nextInt();
            int dwz = 0;
            int[] arr = new int[10];
            for (int i = 0; i < 3; i++) {
                arr[i] = sc.nextInt();
            }
            for (int i = 0; i < 3; i++) {
                if (arr[i] == 0) {
                    dwz = i+1;
                    break;
                }

            }
            if (key == dwz || arr[key-1] == dwz) {
                System.out.println("NO");
            } else {
                System.out.println("YES");
            }

        }
    }
}


import java.io.*;
import java.lang.*;
import java.util.*;
import java.util.Scanner;
public class Marathon{
    static String competetion(int arr[], int key){
        if(key>3)
        return "NO";
        Arrays.sort(arr);
        int count = 0;
        if(arr[0]<=3 && arr[0]>=1 &&arr[0]!= key){
            count++;
        }
        for(int i = 1;i<3;i++){
            if(arr[i]<=3 && arr[i]>=1 && arr[i]!=arr[i-1] && arr[i]!=key){
                count++;
            }
        }
        if(count == 3){
            return "YES";
        }else{
            return "NO";
        }
    }
    public static void main(String[] args){
        int test;
        Scanner input = new Scanner(System.in);
        test = input.nextInt();
        for(int i = 0; i<test;i++){
            int key = input.nextInt();
            int arr[] = new int[3];
            for(int j = 0;i<3;j++){
                arr[j] = input.nextInt();
            }
            System.out.println(competetion(arr, key);
        }
    }

}


import java.util.Scanner;
public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int t = input.nextInt();
        int n;
        for(int i=0;i<t;i++){
            int x = input.nextInt();
            int[] a = new int[3];
            for(int j=0;j<3;j++){
                a[j] = input.nextInt();
            }
            if(a[x-1]==0){
                System.out.println("NO");
            }
            else{
                System.out.println("YES");
            }
            else{
                n = a[x-1];
                if(a[n-1]==0){
                    System.out.println("NO");
                }
                else{
                    System.out.println("YES");
                }
            }
        }
    }
}


import java.util.*
public class MyClass {
    public static void main(String args[]) {
     Scanner sc = new Scanner(System.in);
     int tests;
     tests = sc.nextInt();
     for(int i =0; i<tests; i++){
         int[] arr = new int[3];
         int key = sc.nextInt();
         inputArr(arr);
         int j =0;
         while(j<arr.length){
             if(key = 0 && j!=2){
                 System.out.println("NO");
             }
               if(key = 0 && j=2){
                 System.out.println("YES");
             }

             key = arr[key-1];
             j++;

         }

     }
    }
     public static void inputArr(int[] arr){
         for(int i =0; i<arr.length; i++){
             arr[i] = sc.nextInt();
         }
     }

}


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

public class Main {
    public static void main (String[] args) throws java.lang.Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken()),
            m = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(br.readLine());
        boolean[] used = new boolean[n+1];
        int[] perm = new int[n+1];
        int prev = Integer.parseInt(st.nextToken());
        for (int i=0 ; i<m-1 ; i++) {
            int curr = Integer.parseInt(st.nextToken());
            int step;
            if (curr > prev) step = curr - prev;
            else step = n - prev + curr;
            //    System.out.println("step:" + step);
            if (used[step]) {
                if (perm[prev] != step) {
                    System.out.println(-1);
                    return;
                }
            }
            used[step] = true;
            perm[prev] = step;
            prev = curr;
        }

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

        for (int i=1 ; i<=n ; i++) {
            if (perm[i] == 0) {
                for (int j=1 ; j<=n ; j++) {
                    if (used[j]) continue;

                    perm[i] = j;
                    used[j] = true;
                    break;
                }
            }
        }
        for (int i=1 ; i<=n ; i++) System.out.print(perm[i] + " ");
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

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

    static class TaskB {
        int inputArray = new int[1023];

        public boolean isValid(int ans[], int m, int n) {
            for (int i = 0; i < m - 1; i++) {
                int next = (inputArray[i] + ans[inputArray[i]]) % n;
                if (next == 0) next = n;
                //System.out.println(i+"next ->"+next);
                if (next != inputArray[i + 1]) return false;
            }
            Set<Integer> S = new HashSet<>();
            for (int i = 0; i < n; i++) {
                S.add(ans[i + 1]);
            }
            if (S.size() != n) return false;
            return true;
        }

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

            int myArray[] = new int[1023];
            for (int i = 0; i < m; i++) {
                inputArray[i] = in.nextInt();
            }
            int ans[] = new int[10234];
            int needToadd = 0;
            for (int i = 0; i < m; i++) {
                if (i == 0) myArray[0] = inputArray[0];
                else {
                    if (!(inputArray[i - 1] < inputArray[i])) needToadd += n;
                    myArray[i] = inputArray[i] + needToadd;
                }
            }
            for (int i = 0; i < m; i++) {
                //  out.println(myArray[i]);
            }
            Arrays.fill(ans, -1);
            int visited[] = new int[12345];
            Arrays.fill(visited, 0);
            for (int i = 1; i < m; i++) {
                int node = myArray[i - 1] % n;
                if (node == 0) node = n;
                if (ans[node] != -1) {
                    // out.println(-1);
                    // break;
                }
                visited[node] = 1;
                // out.println("arr fak: "+(myArray[i]-myArray[i-1]));
                ans[node] = myArray[i] - myArray[i - 1];
            }
            ArrayList<Integer> vec = new ArrayList<>();
            ArrayList<Integer> values = new ArrayList<>();
            for (int i = 1; i <= n; i++) {
                if (ans[i] == -1) vec.add(i);
            }
            for (int i = 1; i <= n; i++) {
                if (visited[i] == 0) values.add(i);
            }
            if (values.size() != vec.size()) {
                out.println(-1);
            } else {
                for (int i = 1; i <= values.size(); i++) {
                    ans[vec.get(i - 1)] = values.get(i - 1);
                }
                if (isValid(ans, m, n)) {
                    for (int i = 0; i < n; i++) {
                        out.print(ans[i + 1] + " ");
                    }

                } else out.println(-1);
            }

        }

    }

    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 close() {
            writer.close();
        }

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

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.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 nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

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

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

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

    static class TaskB {
        int inputArray = new int[1023];

        public boolean isValid(int ans[], int m, int n) {
            if (true) return true;
            for (int i = 0; i < m - 1; i++) {
                int next = (inputArray[i] + ans[inputArray[i]]) % n;
                if (next == 0) next = n;
                //System.out.println(i+"next ->"+next);
                if (next != inputArray[i + 1]) return false;
            }
            Set<Integer> S = new HashSet<>();
            for (int i = 0; i < n; i++) {
                S.add(ans[i + 1]);
            }
            if (S.size() != n) return false;
            return true;
        }

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

            int myArray[] = new int[1023];
            for (int i = 0; i < m; i++) {
                inputArray[i] = in.nextInt();
            }
            int ans[] = new int[10234];
            int needToadd = 0;
            for (int i = 0; i < m; i++) {
                if (i == 0) myArray[0] = inputArray[0];
                else {
                    if (!(inputArray[i - 1] < inputArray[i])) needToadd += n;
                    myArray[i] = inputArray[i] + needToadd;
                }
            }
            for (int i = 0; i < m; i++) {
                //  out.println(myArray[i]);
            }
            Arrays.fill(ans, -1);
            int visited[] = new int[12345];
            Arrays.fill(visited, 0);
            for (int i = 1; i < m; i++) {
                int node = myArray[i - 1] % n;
                if (node == 0) node = n;
                if (ans[node] != -1) {
                    // out.println(-1);
                    // break;
                }
                visited[myArray[i] - myArray[i - 1]] = 1;
                // out.println("arr fak: "+(myArray[i]-myArray[i-1]));
                ans[node] = myArray[i] - myArray[i - 1];
            }
            for (int i = 1; i <= n; i++) {
                // if(ans[i]!=-1)visited[i]=1;
                // out.println(ans[i]);
            }
            ArrayList<Integer> vec = new ArrayList<>();
            ArrayList<Integer> values = new ArrayList<>();
            for (int i = 1; i <= n; i++) {
                if (ans[i] == -1) vec.add(i);
            }
            for (int i = 1; i <= n; i++) {
                if (visited[i] == 0) {
                    values.add(i);
                }
            }
            if (values.size() != vec.size()) {
                out.println(-1);
            } else {
                for (int i = 1; i <= values.size(); i++) {
                    ans[vec.get(i - 1)] = values.get(i - 1);
                }
                if (isValid(ans, m, n)) {
                    for (int i = 0; i < n; i++) {
                        out.print(ans[i + 1] + " ");
                    }

                } else out.println(-1);
            }

        }

    }

    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 close() {
            writer.close();
        }

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

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.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 nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

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

        }

    }
}


import java.util.Scanner;

public class MainB {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] child = new int[n];
		in.nextLine();
		String[] array = in.nextLine().split(" ");
		String curContent = "";
		if(n <= m) {
			for(int i=0; i<m-1; i++) {
				int l1 = Integer.parseInt(array[i]);
				int l2 = Integer.parseInt(array[i+1]);
				int content = 0;
				if(l1 < l2) {
					content = l2 - l1;
				}else {
					content = n - l1 + l2;
				}
				if(child[l1-1] == 0 && !curContent.contains(content + "")) {
					child[l1-1] = content;
					curContent += content + "";
				}else if(child[l1-1] == content) {

				}else {
					System.out.println(-1);
					in.close();
					return;
				}
			}
		}else {
			System.out.println(-1);
			in.close();
			break;
		}
		int start = 1;
		for(int i=0; i<child.length; i++) {
			if(child[i] == 0) {
				while(true) {
					if(!curContent.contains(start+"")) {
						child[i] = start;
						start++;
						break;
					}
					start++;
				}
			}
			System.out.print(child[i]);
			if(i != child.length - 1)
				System.out.print(" ");
		}
		in.close();
	}
}


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

public class Main {
static int mod = (int) (1e9+7);
//static InputReader in;
  // static PrintWriter out;

public static void main(String args[] )  {

//in = new InputReader(System.in);
       //out = new PrintWriter(System.out);
       Scanner in = new Scanner (System.in);
       int n = in.nextInt();
       int m= in.nextInt();
       ArrayList<Integer> a = new ArrayList<Integer>();
       for(int i=0;i<m;i++) {
       	int v = in.nextInt();
       	a.add(v);
       }
       int cc= m/n;
       if(cc==0) {
   	System.out.println("0");
    }
    else {
     int[] c= new int[1000];
     for(int i=0;i<m;i++) {
   	 	c[a.get(i)]++;
     }

     for(int i=0;i<a.size()-1;i++) {
   	 	for(int j=i+1;j<a.size();j++) {
   	 	if(a.get(i)==a.get(j)) {
   	 	a.remove(j);
   	 	j--;
   	 	}
   	 	}
     }

     for(int i=0;i<a.size()-1;i++) {
   	 	for(int j=0;j<a.size()-i-1;j++) {

   	 	if(c[a.get(j)] > c[a.get(j+1)]) {
   	 	int temp=a.get(j);
   	 	a.set(j, a.get(j+1));
   	 	a.set(j+1, temp);
   	 	}
   	 	}
     }
    for(int i=0;i<a.size()/2;i++) {
   	int xx = a.get(i);
   	a.set(i, a.get(a.size()-i-1));
   	a.set(a.size()-i-1, xx);
    }
 /*  	for(int i=0;i<a.size();i++)
   	{
   	System.out.println(c[a.get(i)]);
   	}
   	*/

   //System.out.println(cc);
    int z;
    for( z=cc;z>0;z--)
     {
   	int count=0;
    for(int i=0;i<a.size();i++) {
   	count+=c[a.get(i)]/z;
   //	System.out.print(c[a.get(i)]%z);
    }
    if(count>=n) {
   	break;
    }

    }
    System.out.println(z);
    }
       in.close();
       out.close();
}
}


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

public class main {

    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;
        }
    }
    static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static int findGCD(int arr[])
    {
        int result = arr[1];
        for (int i = 1; i <arr.length-1 ; i++)
            result = gcd(arr[i], result);

        return result;
    }
    private static long[] getLongArrar(int size) {
        long arr[] = new long[size + 2];
        for (int i = 0; i <= size; i++) {
            arr[i] = in.nextLong();
        }
        return arr;
    }
    private static String[] getStringArray(int size) {
        String arr[] = new String[size + 2];
        for (int i = 1; i <= size; i++) {
            arr[i] = in.next();
        }
        return arr;
    }
    private static int[] getIntArray(int size) {
        int arr[] = new int[size + 2];
        for (int i = 1; i <= size; i++) {
            arr[i] = in.nextInt();
        }
        return arr;
    }
    private static long[] CumulativeOfArrayCreator(int arr[],int size){
        long cumulative [] =new long[size];
        cumulative[0]=arr[0];
        for(int i=1;i<size;i++){
            cumulative[i]=cumulative[i-1]+arr[i];
        }
        return cumulative;
    }
    private static int ModifiedBinarySearch(long a[],int start,int end,long value){
        // this search INDEX will find greatest element small or equal to the value

        int mid=-1;
        int nearest=start;
        while(start<=end){
            mid=(start+end)/2;
            if(a[mid]<value) {
                nearest=mid;
                start=mid+1;
            }else if (a[mid]>value){
                end=mid-1;
            }else{
                return mid;
            }
        }
        return nearest;
    }

    static FastReader in;
    static StringBuilder out;

    public static void main(String[] args) {
        in=new FastReader();
        out = new StringBuilder();

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

        int a[]=new int[100];

        for(int i=0;i<m;i++){
            a[in.nextInt()]++;
        }
        Arrays.sort(a);
        int index=0;
        for(int i=0;i<100;i++){
            if(a[i]!=0){
                index=i;
                break;
            }
        }

        int eachGet = a[99];
        int personCount = 0;
        while(eachGet>0) {
            personCount=0;
            for(int i=index;i<100;i++){
                personCount+=a[i]/eachGet;
            }
            if(personCount>=n){
                System.out.println(eachGet);
                return;
            }
            eachGet--;
        }

        System.out.println(0);

    }

}

/*
private static void builtSegmentTree(int a[],int n){

        for(int i=n-1;i>0;i--){
            a[i]=a[i*2]+a[(2*i)+1];
        }

    }
    private static void updateSegmentTree(int a[],int n,int index,int value){
        index+=n-1;
        int change = value-a[index];

        while(index>0){
            a[index]+=change;
            index/=2;
        }
    }
    private static int rangeSum(int a[],int n,int l,int r){
        int sum=0;

        l+=n-1;r+=n-1;

        while(l<=r){
            if(l==r){
                sum+=a[l];
                break;
            }
            if(l%2==1) {sum+=a[l]; l++;}
            if(r%2==0) {sum+=a[r]; r--;}
            l/=2;
            r/=2;
        }

        return sum;
    }
    public static void main(String[] args) {

        in = new FastReader();
        out=new StringBuilder();

        int n=in.nextInt();
        int a[]=new int[2*n+1];

        for(int i=n;i<2*n;i++){
            a[i]=in.nextInt();
        }
        builtSegmentTree(a,n);

        //System.out.println("Enter the left and right index of the subarray you want to find the sum of");
        updateSegmentTree(a,n,in.nextInt(),in.nextInt());
        System.out.println(rangeSum(a,n,in.nextInt(),in.nextInt()));

    }
 */

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

public class main {

    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;
        }
    }
    static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static int findGCD(int arr[])
    {
        int result = arr[1];
        for (int i = 1; i <arr.length-1 ; i++)
            result = gcd(arr[i], result);

        return result;
    }
    private static long[] getLongArrar(int size) {
        long arr[] = new long[size + 2];
        for (int i = 0; i <= size; i++) {
            arr[i] = in.nextLong();
        }
        return arr;
    }
    private static String[] getStringArray(int size) {
        String arr[] = new String[size + 2];
        for (int i = 1; i <= size; i++) {
            arr[i] = in.next();
        }
        return arr;
    }
    private static int[] getIntArray(int size) {
        int arr[] = new int[size + 2];
        for (int i = 1; i <= size; i++) {
            arr[i] = in.nextInt();
        }
        return arr;
    }
    private static long[] CumulativeOfArrayCreator(int arr[],int size){
        long cumulative [] =new long[size];
        cumulative[0]=arr[0];
        for(int i=1;i<size;i++){
            cumulative[i]=cumulative[i-1]+arr[i];
        }
        return cumulative;
    }
    private static int ModifiedBinarySearch(long a[],int start,int end,long value){
        // this search INDEX will find greatest element small or equal to the value

        int mid=-1;
        int nearest=start;
        while(start<=end){
            mid=(start+end)/2;
            if(a[mid]<value) {
                nearest=mid;
                start=mid+1;
            }else if (a[mid]>value){
                end=mid-1;
            }else{
                return mid;
            }
        }
        return nearest;
    }

    static FastReader in;
    static StringBuilder out;

    public static void main(String[] args) {
        in=new FastReader();
        out = new StringBuilder();

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

        int a[]=new int[100];

        for(int i=0;i<m;i++){
            a[in.nextInt()]++;
        }
        Arrays.sort(a);
        int index=0;
        for(int i=0;i<100;i++){
            if(a[i]!=0){
                index=i;
                break;
            }
        }

        int eachGet = a[99];
        int personCount = 0;
        while(eachGet>0) {
            personCount=0;
            for(int i=index;i<100;i++){
                personCount+=a[i]/eachGet;
            }
            if(personCount>=n){
                System.out.println(eachGet);
                return;
            }
            eachGet--;
        }

        System.out.println(0);

    }

}

/*
private static void builtSegmentTree(int a[],int n){

        for(int i=n-1;i>0;i--){
            a[i]=a[i*2]+a[(2*i)+1];
        }

    }
    private static void updateSegmentTree(int a[],int n,int index,int value){
        index+=n-1;
        int change = value-a[index];

        while(index>0){
            a[index]+=change;
            index/=2;
        }
    }
    private static int rangeSum(int a[],int n,int l,int r){
        int sum=0;

        l+=n-1;r+=n-1;

        while(l<=r){
            if(l==r){
                sum+=a[l];
                break;
            }
            if(l%2==1) {sum+=a[l]; l++;}
            if(r%2==0) {sum+=a[r]; r--;}
            l/=2;
            r/=2;
        }

        return sum;
    }
    public static void main(String[] args) {

        in = new FastReader();
        out=new StringBuilder();

        int n=in.nextInt();
        int a[]=new int[2*n+1];

        for(int i=n;i<2*n;i++){
            a[i]=in.nextInt();
        }
        builtSegmentTree(a,n);

        //System.out.println("Enter the left and right index of the subarray you want to find the sum of");
        updateSegmentTree(a,n,in.nextInt(),in.nextInt());
        System.out.println(rangeSum(a,n,in.nextInt(),in.nextInt()));

    }
 */


import java.io.*;
import java.util.*;
public class Main { // "Main" should be used for most online judges
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();

    if (n > m) {
      System.out.println(0);
    }
    return;
    //get the counts of each package type
    HashMap<Integer, Integer> typeCounts = new HashMap<Integer, Integer>();

    for (int i = 0; i < m; i++) {
      int a_i = sc.nextInt();
      if (typeCounts.containsKey(a_i)) {
        typeCounts.put(a_i, typeCounts.get(a_i) + 1);
      } else {
        typeCounts.put(a_i, 1);
      }
    }

    int numberDays = 1;

    Set<Integer> values = typeCounts.keySet();
    while (true) {
      int temp = n;
      for (Integer i: values) {
        temp -= i % numberDays;
      }
      if (temp > 0) {
        break;
      }
      numberDays++;
    }

    System.out.println(numberDays);

}
}


import java.util.*;
public class PlanningExpedition
{
public static void main(String[] args)
{
    // TODO Auto-generated method stub
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m =sc.nextInt();
    if(n>m)
    {
        System.out.println(0);
        return;
    }
    ArrayList<Integer> type = new ArrayList<Integer>();
    ArrayList<Integer> number = new ArrayList<Integer>();

    for(int x = 0; x<m; x++)
    {
        type.add(sc.nextInt());
        number.add(1);
    }
    for(int x=m-1;x>=0;x--)
    {
        if(type.indexOf(type.get(x))!=x)
        {
            type.remove(x);
            number.remove(x);
            number.set(type.indexOf(type.get(x)),
            type.get(type.indexOf(type.get(x)))+1);
        }
    }
    int max, start,index;
    for(int x=0;x<number.size();x++)
    {
        max=-1;
        start=x;
        for(int i=x; i<number.size();i++)
        {
            if(number.get(i)>max)
                max=number.get(i);
                index=i;
        }
        number.set(index, number.get(start));
        number.set(start, max);
    }
    if(number.size()>n)
    {
        for(int x=number.size()-1;x>=n;x++)
        {
            number.remove(x);
        }
    }

    int sum;
    int currentP;
    for(int x=1;x<=100;x++)
    {
        sum=0;
        for(int y=0;y<number.size();y++)
        {
            currentP= number.get(y)/x;
            sum+=currentP;
            if(sum>n&&y!=number.size()-1)
            {
                break;
            }
            if(sum==n&&y==number.size()-1)
            {
                System.out.println(x);
                return;
            }
            System.out.println(x-1);
            return ;
        }
    }
}

}


import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
        int p=sc.nextInt();
        int n=sc.nextInt();
        int s=n,f=1;
        while(n>p)
        {
             int i=2;
             while(i<=p && i<=Math.sqrt(s))
             {
                  if(n%i==0)
                  {
                       break;
                       f=0;
                  }
                  i++;
             }
             if(f==1)
             {
                 System.out.print(n);
                 break;
             }
             n--;
        }
        if(n==p)
        System.out.print("-1");
    }
}


import java.util.*;
public class JavaApplication58 {

    private static boolean isPrime(int x)
    {
        int i;
        for(i=2;i<=Math.sqrt(x);i++)
        {
                if(x%i==0)
                {
                    return false;
                }
        }

        return true;
    }

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

        int p=Sc.nextInt();
        int y=Sc.nextInt();
       // int minn=99999999;
        int temp=-1;
        //int prime=-1;
        int k;

        Set<Integer> hs=new HashSet<>();

        for (int i = 2; i <= p; i++)
        {

            if ((i==2||i%2)!=0 && isPrime(i))
            {
                temp=y-(y%i);
                hs.add(temp);
            }
        }

        //System.out.println(hs);
        k=y;
        while(hs.contains(k)==true && k>p)
        {
            k--;
        }

        if(k>p)
        {
            System.out.println(k);
        }
        else
        {
            System.out.println(-1);
        }

    }

}


package contest467;

public class Dev2B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int p = sc.nextInt();
        int y = sc.nextInt();
        boolean solutionFound = false;
        for (int i = y; i > p; i--) {
            boolean isPrime = true;
            for (int j = 2; j <=p; j++) {
                if (i % j == 0) {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime) {
                solutionFound = true;
                System.out.println(i);
                break;
            }
        }
        if (!solutionFound) {
            System.out.println(-1);
        }
    }
}


import java.util.*;

public class VileGrasshoppers{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int y = sc.nextInt();
		sc.close();

		/*
		** TLE
		Set<Integer> set = new HashSet<>();
		for (int i = 2; i <= p; i++) {
			for (int j = 2; j <= y / i; j++) {
				if (!set.contains(i * j)) {
					// System.out.println("got one: " + i * j);
					set.add(i * j);
				}
			}
		}

		for (int i = y; i > p; i--) {
			if (!set.contains(i)) {
				System.out.println(i);
				return ;
			}
		}*/

		for (int i = y; i > p; i--) {
			if (isValid(i)) {
				System.out.println(i);
				return;
			}
		}

		System.out.println(-1);
	}
	private static boolean isValid(int num, int p, int y) {
		int end = Math.min(p, Math.sqrt(y));
		for (int i = 2; i < end; i++) {
			if (num % i == 0) {
				return false;
			}
		}
		return true;
	}
}


package semana11

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

public class logo {
	static int largo, n;
	static String instr;
	static int[][][][] dp = new int[2][200][500][100];
	static boolean[][][][] vis = new boolean[2][200][500][100];

	static int dfs(int dir, int cd, int pos, int cur){
		if (cur < 0) return 0;
		if (cd == largo) {
			if (cur > 0) return 0;
			else return Math.abs(pos-200);
		}

		if(vis[dir][cd][pos][cur]==true)
			return dp[dir][cd][pos][cur];
		int ret = 0;
		int mv = (dir == 1) ? -1 : 1;

		if (instr.charAt(cd) == 'T')
			ret = Math.max(ret, Math.max(dfs(1^dir, cd+1, pos, cur), dfs(dir, cd+1, pos+mv, cur-1)));
		else
			ret = Math.max(ret, Math.max(dfs(dir, cd+1, pos+mv, cur), dfs(1^dir, cd+1, pos, cur-1)));

		vis[dir][cd][pos][cur] = true;
		dp[dir][cd][pos][cur] = ret;

		return ret;
	}

	static public void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		instr = r.readLine();
		largo = instr.length();
		n = Integer.parseInt(r.readLine());

		int ans = Integer.MIN_VALUE;
		for (int i = n; i >= 0; i = i - 2){
			ans = Math.max(ans, dfs(0,0,200,i));
		}
		System.out.println(ans);

	}
}


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

public class C {

	public C () throws IOException {
		char [] commands = sc.next().toCharArray();
		int N = sc.nextInt();
		print(solve(commands, N));
	}

	public int solve (char [] C, int N) {

		int L = C.length;
		while (N > 0) {
			// 1. All Fs
			String cmd = new String(C);
			if (cmd.indexOf('T') == -1) {
				C[0] = 'T';
				--N;
			}

			// 2. N == 1
			else if (N == 1) {
				int S = -1;
				for (int i = 0; i < L; ++i) {
					C[i] = ch(C[i]);
					S = Math.max(S, eval(C));
					C[i] = ch(C[i]);
				}
				return S;
			}

			else {
				int count = 0;
				for (int i = 0; i < L; ++i) {
					if (C[i] == 'T')
						++count;
				}

				// 3. N >= 2, just one T
				if (count == 1) {
					for (int i = 0; i < L; ++i) {
						if (C[i] == 'T')
							C[i] = 'F';
					}
					--N;
				} else {
					int S = 0, x = -1, y = -1, z = -1;
					for (int i = 0; i < L; ++i) {
						// Look for the best pair to change - prefer farther ones!
						for (int j = i+1; j < L; ++j)
							if (C[i] == 'T' && C[j] == 'T') {
								C[i] = ch(C[i]); C[j] = ch(C[j]);
								int E = eval(C);
								if (E >= S) {
									S = E; x = i; y = j;
								}
								C[i] = ch(C[i]); C[j] = ch(C[j]);
						}
						// Look for best single to change - prefer farther ones!
						if (C[i] == 'T') {
							C[i] = ch(C[i]);
							int E = eval(C);
							if (E >= S) {
								S = E; z = i;
							}
							C[i] = ch(C[i]);
						}
					}

					if (z >= 0) {
						char [] D = new char[L];
						for (int i = 0; i < L; ++i)
							D[i] = C[i];
						C[x] = C[y] = D[z] = 'F';
						return Math.max(solve(C, N-2), solve(D, N-1))
					} else
						return solve(C, N-2);
				}
			}
		}

		return eval(C);
	}

	int eval (char [] C) {
		int x = 0, d = 1;
		for (char c : C) {
			if (c == 'T')
				d = -d;
			if (c == 'F')
				x += d;
		}
		return Math.abs(x);
	}

	char ch (char X) {
		if (X == 'F') return 'T';
		else return 'F';
	}

	////////////////////////////////////////////////////////////////////////////////////

	static Scanner sc;
	static long t;

	static void print2 (Object o) {
		System.out.println(o);
	}

	static void print (Object o) {
		print2(o);
		//print2((millis() - t) / 1000.0);
		System.exit(0);
	}

	static void run () throws IOException {
		sc = new Scanner(System.in);
		new C();
	}

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

	static long millis() {
		return System.currentTimeMillis();
	}
}


import java.io.*;

public class B {
      private static StreamTokenizer in = null;
    private static PrintWriter out = null;

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

    static long nextLong() throws IOException {
        in.nextToken();
        return (long) in.nval;
    }

    static double nextDouble() throws IOException {
        in.nextToken();
        return (double) in.nval;
    }

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

    public static void main(String[] args) throws IOException {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        // Here is the solution:
        String str = nextString();
        int n = nextInt();
        out.println(new A().solve(str, n));
        out.flush();
    }

    String string;
    private int doit(int p, int c, boolean d) {
        if (c < 0)
            return -1;
        if (p == 0) {
            if (c % 2 == 0)
                return 0;
            else
                return -1;
        }

        if (visit[p][c][d?0:1])
            return dp[p][c][d?0:1];

        int res = -1;
        if (string.charAt(p-1) == 'F') {
            res = Math.max(doit(p - 1, c, d) + (d ? 1 : -1), doit(p - 1, c - 1, !d));
        } else {
            res = Math.max(doit(p - 1, c - 1, d) + (d ? 1 : - 1), doit(p - 1, c, !d));
        }

        visit[p][c][(d?0:1)] = true;
        return dp[p][c][d?0:1] = res;
    }

    boolean[][][] visit;
    int[][][] dp;
    public int solve(String str, int n) {
        this.string = str;
        int len = str.length();
        visit = new boolean[len+1][n+1][2];
        dp = new int[len+1][n+1][2];
        return Math.max(doit(len, n, true), doit(len, n, false));
    }
}


//package com.codeforces.Practise;

import java.io.*;

public class RubikCubeColoring {
    //when you get WA and you are okk with your solution then try out some edge cases means on which test case your code fails
    // because sometimes your writing code mistake
    // Consistency will always give you great Result
    // Don't Confuse Always make things simple
    // Don't afraid after seeing the problem instead dive deep into it to get better understanding
    //Experience is the name of the game
    // You won't fail until you stop trying.......
    // you can solve one problem by many approaches. when you stuck you are going to learn something new okk
    // Everything is easy. you feel its hard because of you don't know, and you not understand it very well.
    ////     How to Improve Your problem-solving skill ??( By practise ). ***simple
    /// ==>> Solve problems slightly above of your level (to know some logic and how to approach cp problems)
    //       Otherwise You will stay as it is okk. Learn from other code as well.
    /////////////////////////////////////////////////////////////////////////
    ///      How to Solve Problem in CP ? (you need to come up with brainstorm(Learning))  ( if you feel problem is hard then your approach is wrong )
    // ==>> Step01 :- Understanding problem statement clearly. Then Only Move Forward (Because Everything is mentioned in problem statement).
    //      Step02 :- Think a lot about Solution. if you are confident that your solution might be correct Then only Move Forward
    //      Step03 :- First think of brute force then move to optimal approach
    //      Step04 :- Finally Code ( there is no any sense to code. if you not follow about steps okk)
    ///////////////////////////////////////////////////////////////////////////
    /* Iterative Function to calculate (x^y) in O(log y) */
    static long getpower(long x, long y, long mod) {
        long res = 1L; // Initialize result
        x = x % mod; // Update x if it is more than or
        // equal to p
        if (x == 0)
            return 0; // In case x is divisible by p;
        while (y > 0) {
            // If y is odd, multiply x with result
            if ((y & 1) != 0)
                res = (res * x) % mod;
            // y must be even now
            y = y >> 1; // y = y/2
            x = (x * x) % mod;
        }
        return res;
    }
    public static void main(String[] args) throws IOException {
        Reader scan = new Reader();
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int t = scan.nextInt();
        long mod= (long) (1e9+7);
        while (t-- > 0) {
             long k=scan.nextInt();
             long power=getpower(2L,k,mod)-2L;
             long ans=(6L*(getpower(4L,power,mod)))%mod;
             bw.write(ans+"");
             bw.newLine();
             bw.flush();
        }
    }
    //FAST READER
    static class Reader {
        public int BS = 1<<16;
        public char NC = (char)0;
        byte[] buf = new byte[BS];
        int bId = 0, size = 0;
        char c = NC;
        double num = 1;
        BufferedInputStream in;

        public Reader() {
            in = new BufferedInputStream(System.in, BS);
        }

        public Reader(String s) throws FileNotFoundException {
            in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
        }

        public char nextChar(){
            while(bId==size) {
                try {
                    size = in.read(buf);
                }catch(Exception e) {
                    return NC;
                }
                if(size==-1)return NC;
                bId=0;
            }
            return (char)buf[bId++];
        }

        public int nextInt() {
            return (int)nextLong();
        }

        public long nextLong() {
            num=1;
            boolean neg = false;
            if(c==NC)c=nextChar();
            for(;(c<'0' || c>'9'); c = nextChar()) {
                if(c=='-')neg=true;
            }
            long res = 0;
            for(; c>='0' && c <='9'; c=nextChar()) {
                res = (res<<3)+(res<<1)+c-'0';
                num*=10;
            }
            return neg?-res:res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c!='.' ? cur:cur+(cur < 0 ? -1*nextLong()/num : nextLong()/num);
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=nextChar();
            while(c>32) {
                res.append(c);
                c=nextChar();
            }
            return res.toString();
        }
    }
}