import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

import javax.swing.text.html.CSS;

import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.UncheckedIOException;
import java.lang.Thread.State;
import java.lang.reflect.Field;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.StandardCharsets;

public class Main {
	static final long MOD1=1000000007;
	static final long MOD=998244353;
	static int ans=0;
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		int t = sc.nextInt();
		for (int i = 0; i <t; i ++) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int k = sc.nextInt();
			out.println(solve(n, m, k));
		}
		out.flush();
	}
	static String solve(int n,int m,int k) {
		if (n%2==0){
			if (m%2==0) {
				if (k%2==0) {
					return "YES";
				}else {
					return "NO";
				}
			}else {
				if (k%2==0&&k*2<=n*(m-1)) {
					return "YES";
				}else {
					return "NO";
				}
			}
		}else {
			if (k*2<m){
				return "NO";
			}else {
				k -= m/2;
				if (k%2==0) {
					return "YES";
				}else {
					return "NO";
				}
			}
		}
	}
	static class InputReader {
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
		public double[] nextDoubleArray(int n) {
			double[] a = new double[n];
			for (int i = 0; i < n; i++)
				a[i] = nextDouble();
			return a;
		}
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

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


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.StringTokenizer;
import java.util.TreeSet;

/**
 *
 * @author sultan.of.swing
 *
 */

public class TaskC {

	public FasterScanner mFScanner;
	public PrintWriter mOut;

	public TaskC() {
		mFScanner = new FasterScanner();
		mOut = new PrintWriter(System.out);
	}

	public void solve() {
		int n, m;
		char op[];
		int num[];
		int i;
		int unconfirmed;
		String str;
		HashSet<Integer> loggedInSet;
		HashSet<Integer> hasActed;
		TreeSet<Integer> leaderSet;
		HashSet<Integer> missing;

		n = mFScanner.nextInt();
		m = mFScanner.nextInt();

		num = new int[m];
		op = new char[m];

		for (i = 0; i < m; i++) {
			str = mFScanner.nextLine();
			StringTokenizer st = new StringTokenizer(str);
			op[i] = st.nextToken().charAt(0);
			num[i] = Integer.parseInt(st.nextToken()) - 1;
		}

		loggedInSet = new HashSet<>();
		hasActed = new HashSet<>();

		for (i = 0; i < n; i++)
			loggedInSet.add(i);

		for (i = 0; i < m; i++) {

			if (op[i] == '+' && !hasActed.contains(num[i]))
				loggedInSet.remove(num[i]);

			hasActed.add(num[i]);
		}

		unconfirmed = n - hasActed.size();

		if (loggedInSet.size() <= unconfirmed && op[0] == '+') {
			loggedInSet.add(num[0]);
		}

		leaderSet = new TreeSet<>(loggedInSet);
		missing = new HashSet<>();

		for (i = 0; i < m; i++) {

			if (op[i] == '+') {

				loggedInSet.add(num[i]);

				for (int miss : missing) {
					if (miss != num[i])
						leaderSet.remove(miss);
				}

				missing.clear();

			} else {
				loggedInSet.remove(num[i]);

				if (loggedInSet.size() > unconfirmed) {
					leaderSet.remove(num[i]);
				} else {
					missing.add(num[i]);
				}

			}

		}

		mOut.println(leaderSet.size());

		for (int l : leaderSet) {
			mOut.print((l + 1) + " ");
		}

		mOut.println();

	}

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

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

	public static void main(String[] args) {
		TaskC mSol = new TaskC();
		mSol.solve();
		mSol.flush();
		mSol.close();
	}

	class FasterScanner {
		private InputStream mIs;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FasterScanner() {
			this(System.in);
		}

		public FasterScanner(InputStream is) {
			mIs = is;
		}

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

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

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

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

		public 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 double nextDouble() {
			Double next;
			next = Double.parseDouble(nextString());
			return next;
		}

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

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

		public char[] nextCharArray(int N) {
			int i;
			char[] array;
			String str;

			array = new char[N];

			i = 0;

			str = nextLine();

			for (i = 0; i < N && i < str.length(); i++) {
				array[i] = str.charAt(i);
			}

			return array;
		}

		public char[][] nextChar2DArray(int M, int N) {
			int i;
			char[][] array;

			array = new char[M][N];

			i = 0;

			for (i = 0; i < M; i++) {
				array[i] = nextCharArray(N);
			}

			return array;
		}

		public int[] nextIntArray(int N) {
			int i;
			int[] array;

			array = new int[N];

			i = 0;

			for (i = 0; i < N; i++) {
				array[i] = nextInt();
			}

			return array;
		}

		public int[][] nextInt2DArray(int M, int N) {
			int i;
			int[][] array;

			array = new int[M][N];

			i = 0;

			for (i = 0; i < M; i++) {
				array[i] = nextIntArray(N);
			}

			return array;
		}

		public long[] nextLongArray(int N) {
			int i;
			long[] array;

			array = new long[N];

			i = 0;

			for (i = 0; i < N; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public long[][] nextLong2DArray(int M, int N) {
			int i;
			long[][] array;

			array = new long[M][N];

			i = 0;

			for (i = 0; i < M; i++) {
				array[i] = nextLongArray(N);
			}

			return array;
		}

		public double[] nextDoubleArray(int N) {
			int i;
			double[] array;

			array = new double[N];

			for (i = 0; i < N; i++) {
				array[i] = nextDouble();
			}

			return array;
		}

		public double[][] nextDouble2DArray(int M, int N) {
			int i;
			double[][] array;

			array = new double[M][N];

			for (i = 0; i < M; i++) {
				array[i] = nextDoubleArray(N);
			}

			return array;
		}

	}
}


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

public class c1
{
	static Scanner sc;
	static PrintStream ps;
	public static void main(String [] args)
	{
		ps= System.out;
		sc= new Scanner(System.in);
		int f = sc.nextInt();
		int [] p = new int[f+1];
		int max = 0, maxi = 1;
		for(int i = 1; i <= f; i++)
		{
			p[i] = sc.nextInt();
			if(max < p[i])
			{
				max = p[i];
				maxi = i;
			}
		}
		maxi = (f+1)/2;
		///ps.println(max+" "+maxi);
		int minPow = 100000000;
		for(int x = 1; x <=f; x++){
			int pow = 0;
			for(int i = 1; i <= f; i++)
			{
				pow += p[i]*(2*(Math.abs(i-x)+Math.abs(1-x)+Math.abs(i-1)));
			//ps.println(pow);
			}
			minPow = minPow > pow? pow:minPow;
		}
		ps.println(minPow);

	}
}


import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class G1096 {
	public static final int[] NTTPrimes = {1053818881, 1051721729, 1045430273, 1012924417, 1007681537, 1004535809, 998244353, 985661441, 976224257, 975175681};
	public static final int[] NTTPrimitiveRoots = {7, 6, 3, 5, 3, 3, 3, 3, 3, 17};
//	public static final int[] NTTPrimes = {1012924417, 1004535809, 998244353, 985661441, 975175681, 962592769, 950009857, 943718401, 935329793, 924844033};
//	public static final int[] NTTPrimitiveRoots = {5, 3, 3, 3, 17, 7, 7, 7, 3, 5};

	public static long[] convoluteSimply(long[] a, long[] b, int P, int g) {
		int m = Math.max(2, Integer.highestOneBit(Math.max(a.length, b.length) - 1) << 2);
		long[] fa = nttmb(a, m, false, P, g);
		long[] fb = a == b ? fa : nttmb(b, m, false, P, g);
		for (int i = 0; i < m; i++) {
			fa[i] = fa[i] * fb[i] % P;
		}
		return nttmb(fa, m, true, P, g);
	}

	public static long[] convolute(long[] a, long[] b) {
		int USE = 2;
		int m = Math.max(2, Integer.highestOneBit(Math.max(a.length, b.length) - 1) << 2);
		long[][] fs = new long[USE][];
		for (int k = 0; k < USE; k++) {
			int P = NTTPrimes[k], g = NTTPrimitiveRoots[k];
			long[] fa = nttmb(a, m, false, P, g);
			long[] fb = a == b ? fa : nttmb(b, m, false, P, g);
			for (int i = 0; i < m; i++) {
				fa[i] = fa[i] * fb[i] % P;
			}
			fs[k] = nttmb(fa, m, true, P, g);
		}

		int[] mods = Arrays.copyOf(NTTPrimes, USE);
		long[] gammas = garnerPrepare(mods);
		int[] buf = new int[USE];
		for (int i = 0; i < fs[0].length; i++) {
			for (int j = 0; j < USE; j++) {
				buf[j] = (int) fs[j][i];
			}
			long[] res = garnerBatch(buf, mods, gammas);
			long ret = 0;
			for (int j = res.length - 1; j >= 0; j--) {
				ret = ret * mods[j] + res[j];
			}
			fs[0][i] = ret;
		}
		return fs[0];
	}

	public static long[] convolute1(long[] a, long[] b) {
		int m = Math.max(2, Integer.highestOneBit(Math.max(a.length, b.length) - 1) << 2);
		int P = NTTPrimes[0], g = NTTPrimitiveRoots[0];
		long[] fa = nttmb(a, m, false, P, g);
		long[] fb = a == b ? fa : nttmb(b, m, false, P, g);
		for (int i = 0; i < m; i++) {
			fa[i] = fa[i] * fb[i] % P;
		}
		long[] f = nttmb(fa, m, true, P, g);
		return f;
	}
	static long[] multiply(long a[],long b[],int mod)
	{
		long v=mod;
		v*=mod;
		long ans[]=new long[a.length+b.length-1];
		for(int i=0;i<a.length;i++)
			for(int j=0;j<b.length;j++)
			{
				ans[i+j]+=a[i]*b[j];
				if(ans[i+j]>=v)
					ans[i+j]-=v;
			}
		for(int i=0;i<ans.length;i++)
			ans[i]%=mod;
		return ans;
	}
	public static long[] convolute(long[] a, long[] b, int USE, int mod) {
		if(a.length+b.length<=200)
			return multiply(a,b,mod);
		int m = Math.max(2, Integer.highestOneBit(Math.max(a.length, b.length) - 1) << 2);
		long[][] fs = new long[USE][];
		for (int k = 0; k < USE; k++) {
			int P = NTTPrimes[k], g = NTTPrimitiveRoots[k];
			long[] fa = nttmb(a, m, false, P, g);
			long[] fb = a == b ? fa : nttmb(b, m, false, P, g);
			for (int i = 0; i < m; i++) {
				fa[i] = fa[i] * fb[i] % P;
			}
			fs[k] = nttmb(fa, m, true, P, g);
		}

		int[] mods = Arrays.copyOf(NTTPrimes, USE);
		long[] gammas = garnerPrepare(mods);
		int[] buf = new int[USE];
		for (int i = 0; i < fs[0].length; i++) {
			for (int j = 0; j < USE; j++) {
				buf[j] = (int) fs[j][i];
			}
			long[] res = garnerBatch(buf, mods, gammas);
			long ret = 0;
			for (int j = res.length - 1; j >= 0; j--) {
				ret = (ret * mods[j] + res[j]) % mod;
			}
			fs[0][i] = ret;
		}
		return fs[0];
	}

	// static int[] wws = new int[270000]; // outer faster
	// Modifed Montgomery + Barrett
	private static long[] nttmb(long[] src, int n, boolean inverse, int P, int g) {
		long[] dst = Arrays.copyOf(src, n);

		int h = Integer.numberOfTrailingZeros(n);
		long K = Integer.highestOneBit(P) << 1;
		int H = Long.numberOfTrailingZeros(K) * 2;
		long M = K * K / P;

		int[] wws = new int[1 << h - 1];
		long dw = inverse ? pow(g, P - 1 - (P - 1) / n, P) : pow(g, (P - 1) / n, P);
		long w = (1L << 32) % P;
		for (int k = 0; k < 1 << h - 1; k++) {
			wws[k] = (int) w;
			w = modh(w * dw, M, H, P);
		}
		long J = invl(P, 1L << 32);
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < 1 << i; j++) {
				for (int k = 0, s = j << h - i, t = s | 1 << h - i - 1; k < 1 << h - i - 1; k++, s++, t++) {
					long u = (dst[s] - dst[t] + 2 * P) * wws[k];
					dst[s] += dst[t];
					if (dst[s] >= 2 * P) {
						dst[s] -= 2 * P;
					}
//					long Q = (u&(1L<<32)-1)*J&(1L<<32)-1;
					long Q = (u << 32) * J >>> 32;
					dst[t] = (u >>> 32) - (Q * P >>> 32) + P;
				}
			}
			if (i < h - 1) {
				for (int k = 0; k < 1 << h - i - 2; k++) {
					wws[k] = wws[k * 2];
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (dst[i] >= P) {
				dst[i] -= P;
			}
		}
		for (int i = 0; i < n; i++) {
			int rev = Integer.reverse(i) >>> -h;
			if (i < rev) {
				long d = dst[i];
				dst[i] = dst[rev];
				dst[rev] = d;
			}
		}

		if (inverse) {
			long in = invl(n, P);
			for (int i = 0; i < n; i++) {
				dst[i] = modh(dst[i] * in, M, H, P);
			}
		}

		return dst;
	}

	// Modified Shoup + Barrett
	private static long[] nttsb(long[] src, int n, boolean inverse, int P, int g) {
		long[] dst = Arrays.copyOf(src, n);

		int h = Integer.numberOfTrailingZeros(n);
		long K = Integer.highestOneBit(P) << 1;
		int H = Long.numberOfTrailingZeros(K) * 2;
		long M = K * K / P;

		long dw = inverse ? pow(g, P - 1 - (P - 1) / n, P) : pow(g, (P - 1) / n, P);
		long[] wws = new long[1 << h - 1];
		long[] ws = new long[1 << h - 1];
		long w = 1;
		for (int k = 0; k < 1 << h - 1; k++) {
			wws[k] = (w << 32) / P;
			ws[k] = w;
			w = modh(w * dw, M, H, P);
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < 1 << i; j++) {
				for (int k = 0, s = j << h - i, t = s | 1 << h - i - 1; k < 1 << h - i - 1; k++, s++, t++) {
					long ndsts = dst[s] + dst[t];
					if (ndsts >= 2 * P) {
						ndsts -= 2 * P;
					}
					long T = dst[s] - dst[t] + 2 * P;
					long Q = wws[k] * T >>> 32;
					dst[s] = ndsts;
					dst[t] = ws[k] * T - Q * P & (1L << 32) - 1;
				}
			}
//			dw = dw * dw % P;
			if (i < h - 1) {
				for (int k = 0; k < 1 << h - i - 2; k++) {
					wws[k] = wws[k * 2];
					ws[k] = ws[k * 2];
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (dst[i] >= P) {
				dst[i] -= P;
			}
		}
		for (int i = 0; i < n; i++) {
			int rev = Integer.reverse(i) >>> -h;
			if (i < rev) {
				long d = dst[i];
				dst[i] = dst[rev];
				dst[rev] = d;
			}
		}

		if (inverse) {
			long in = invl(n, P);
			for (int i = 0; i < n; i++) {
				dst[i] = modh(dst[i] * in, M, H, P);
			}
		}

		return dst;
	}

	static final long mask = (1L << 31) - 1;

	public static long modh(long a, long M, int h, int mod) {
		long r = a - ((M * (a & mask) >>> 31) + M * (a >>> 31) >>> h - 31) * mod;
		return r < mod ? r : r - mod;
	}

	private static long[] garnerPrepare(int[] m) {
		int n = m.length;
		assert n == m.length;
		if (n == 0) {
			return new long[0];
		}
		long[] gamma = new long[n];
		for (int k = 1; k < n; k++) {
			long prod = 1;
			for (int i = 0; i < k; i++) {
				prod = prod * m[i] % m[k];
			}
			gamma[k] = invl(prod, m[k]);
		}
		return gamma;
	}

	private static long[] garnerBatch(int[] u, int[] m, long[] gamma) {
		int n = u.length;
		assert n == m.length;
		long[] v = new long[n];
		v[0] = u[0];
		for (int k = 1; k < n; k++) {
			long temp = v[k - 1];
			for (int j = k - 2; j >= 0; j--) {
				temp = (temp * m[j] + v[j]) % m[k];
			}
			v[k] = (u[k] - temp) * gamma[k] % m[k];
			if (v[k] < 0) {
				v[k] += m[k];
			}
		}
		return v;
	}

	private static long pow(long a, long n, long mod) {
		//		a %= mod;
		long ret = 1;
		int x = 63 - Long.numberOfLeadingZeros(n);
		for (; x >= 0; x--) {
			ret = ret * ret % mod;
			if (n << 63 - x < 0) {
				ret = ret * a % mod;
			}
		}
		return ret;
	}

	private static long invl(long a, long mod) {
		long b = mod;
		long p = 1, q = 0;
		while (b > 0) {
			long c = a / b;
			long d;
			d = a;
			a = b;
			b = d % b;
			d = p;
			p = q;
			q = d - c * q;
		}
		return p < 0 ? p + mod : p;
	}
	static class Scanner {
		BufferedReader br;
		StringTokenizer tk = new StringTokenizer("");

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

		public int nextInt() throws IOException {
			if (tk.hasMoreTokens())
				return Integer.parseInt(tk.nextToken());
			tk = new StringTokenizer(br.readLine());
			return nextInt();
		}

		public long nextLong() throws IOException {
			if (tk.hasMoreTokens())
				return Long.parseLong(tk.nextToken());
			tk = new StringTokenizer(br.readLine());
			return nextLong();
		}

		public String next() throws IOException {
			if (tk.hasMoreTokens())
				return (tk.nextToken());
			tk = new StringTokenizer(br.readLine());
			return next();
		}

		public String nextLine() throws IOException {
			tk = new StringTokenizer("");
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			if (tk.hasMoreTokens())
				return Double.parseDouble(tk.nextToken());
			tk = new StringTokenizer(br.readLine());
			return nextDouble();
		}

		public char nextChar() throws IOException {
			if (tk.hasMoreTokens())
				return (tk.nextToken().charAt(0));
			tk = new StringTokenizer(br.readLine());
			return nextChar();
		}

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

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

		public int[] nextIntArrayOneBased(int n) throws IOException {
			int a[] = new int[n + 1];
			for (int i = 1; i <= n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArrayOneBased(int n) throws IOException {
			long a[] = new long[n + 1];
			for (int i = 1; i <= n; i++)
				a[i] = nextLong();
			return a;
		}

	}

	public static void main(String args[]) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					solve();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();

	}

	static void solve() throws IOException {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n=in.nextInt()/2;
		long b[]=new long[10];
		for(int i=in.nextInt();i>0;i--)
			b[in.nextInt()]=1;
		long mod=998244353;
		long ans[]=new long[1];
		ans[0]=1;
		while(n>0){
			if((n&1)==1){
				ans=convoluteSimply(ans,b,(int)mod,3);
				int sz=ans.length-1;
				while(sz>0 && ans[sz]==0)
					sz--;
				if(ans.length-sz > 100)
					ans=Arrays.copyOf(ans,sz+1);
			}
			n>>=1;
			b=convoluteSimply(b,b,(int)mod,3);
			int sz=b.length-1;
			while(sz>0 && b[sz]==0)
				sz--;
			if(b.length-sz > 100)
				b=Arrays.copyOf(b,sz+1);
		}
		long res=0;
		for(int i=0;i<ans.length;i++){
			res+=(ans[i]*ans[i]);
			res%=mod;
		}
		out.println(res);
		out.close();

	}
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class cf1 {
    static long mod = (long)1e9 + 7;
    static long mod1 = 998244353;
    static FastScanner f;
    static PrintWriter pw = new PrintWriter(System.out);
    static Scanner S = new Scanner(System.in);
    static long x0; static long y0;
    static int inf = (int)(1e9) + 5;
    static long iinf = (long)(1e18);
    static double eps = (double)1e-4;
    static void solve()throws IOException {
        int a = f.ni(); int b = f.ni();
        int p1 = 0 , p2 = 0 , d = 0;
        for (int i = 1; i <= 6; ++i) {
            int d1 = Math.abs(a - i);
            int d2 = Math.abs(b - i);
            if (d1 == d2) ++d;
            else if (d1 > d2) ++p2;
            else ++p1;
        }
        p(p1 + " " + d + " " + p2);
    }
    public static void main(String[] args)throws NumberFormatException , IOException {
        init();
        boolean tc = false;
        int t = tc ? f.ni() : 1;
        while(t --> 0) solve();
        pw.flush();
        pw.close();
    }

/******************************END OF MAIN PROGRAM*******************************************/
    public static void init()throws IOException{if(System.getProperty("ONLINE_JUDGE")==null){f=new FastScanner("");}else{f=new FastScanner(System.in);}}
    public static class FastScanner {
        BufferedReader br;StringTokenizer st;
        FastScanner(InputStream stream){try{br=new BufferedReader(new InputStreamReader(stream));}catch(Exception e){e.printStackTrace();}}
        FastScanner(String str){try{br=new BufferedReader(new FileReader("!a.txt"));}catch(Exception e){e.printStackTrace();}}
        String next(){while(st==null||!st.hasMoreTokens()){try{st=new StringTokenizer(br.readLine());}catch(IOException e){e.printStackTrace();}}return st.nextToken();}
        String nextLine()throws IOException{return br.readLine();}int ni(){return Integer.parseInt(next());}long nl(){return Long.parseLong(next());}double nd(){return Double.parseDouble(next());}
    }
    public static void pn(Object o){pw.println(o);}
    public static void p(Object o){pw.print(o);}
    public static void pni(Object o){pw.println(o);pw.flush();}
    static int gcd(int a,int b){if(b==0)return a;else{return gcd(b,a%b);}}
    static long gcd(long a,long b){if(b==0l)return a;else{return gcd(b,a%b);}}
    static long lcm(long a,long b){return (a*b/gcd(a,b));}
    static long exgcd(long a,long b){if(b==0){x0=1;y0=0;return a;}long temp=exgcd(b,a%b);long t=x0;x0=y0;y0=t-a/b*y0;return temp;}
    static long pow(long a,long b){long res=1;while(b>0){if((b&1)==1)res=res*a;b>>=1;a=a*a;}return res;}
    static long mpow(long a,long b){long res=1;while(b>0l){if((b&1)==1l)res=((res%mod)*(a%mod))%mod;b>>=1l;a=((a%mod)*(a%mod))%mod;}return res;}
    static long mul(long a , long b){return ((a%mod)*(b%mod)%mod);}
    static long adp(long a , long b){return ((a%mod)+(b%mod)%mod);}
    static int log2(int x){return (int)(Math.log(x)/Math.log(2));}
    static boolean isPrime(long n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(long i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
    static boolean isPrime(int n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(int i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
    static HashSet<Long> factors(long n){HashSet<Long> hs=new HashSet<Long>();for(long i=1;i<=(long)Math.sqrt(n);i++){if(n%i==0){hs.add(i);hs.add(n/i);}}return hs;}
    static HashSet<Integer> factors(int n){HashSet<Integer> hs=new HashSet<Integer>();for(int i=1;i<=(int)Math.sqrt(n);i++){if(n%i==0){hs.add(i);hs.add(n/i);}}return hs;}
    static HashSet<Long> pf(long n){HashSet<Long> ff=factors(n);HashSet<Long> res=new HashSet<Long>();for(Long i:ff)if(isPrime(i))res.add(i);return res;}
    static HashSet<Integer> pf(int n){HashSet<Integer> ff=factors(n);HashSet<Integer> res=new HashSet<Integer>();for(Integer i:ff)if(isPrime(i))res.add(i);return res;}
    static int[] inpint(int n){int arr[]=new int[n+1];for(int i=1;i<=n;++i){arr[i]=f.ni();}return arr;}
    static long[] inplong(int n){long arr[] = new long[n+1];for(int i=1;i<=n;++i){arr[i]=f.nl();}return arr;}
    static boolean ise(int x){return ((x&1)==0);}static boolean ise(long x){return ((x&1)==0);}
    static int gnv(char c){return Character.getNumericValue(c);}//No. of integers less than equal to i in ub
    static int log(long x){return x==1?0:(1+log(x/2));} static int log(int x){return x==1?0:(1+log(x/2));}
    static int upperbound(int a[],int i){int lo=0,hi=a.length-1,mid=0;int count=0;while(lo<=hi){mid=(lo+hi)/2;if(a[mid]<=i){count=mid+1;lo=mid+1;}else hi=mid-1;}return count;}
    static void sort(int[] a){ArrayList<Integer> l=new ArrayList<>();for(int i:a)l.add(i);Collections.sort(l);for(int i=0;i<a.length;++i)a[i]=l.get(i);}
    static void sort(long[] a){ArrayList<Long> l=new ArrayList<>();for(long i:a)l.add(i);Collections.sort(l);for(int i=0;i<a.length;++i)a[i]=l.get(i);}
    static void sort(ArrayList<Integer> a){Collections.sort(a);}//!Precompute fact in ncr()!
    static int nextPowerOf2(int n){int count=0;if(n>0&&(n&(n-1))==0)return n;while(n!=0){n>>=1;count += 1;}return 1<<count;}
}


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

public class Titles
{
    public static String replaceIndex(String str, int i, char c)
    {
        String result = str.substring(0, i) + c
                + str.substring(i + 1, str.length());
        return result;
    }

    static boolean finished = false;
    public static int getFFlse(boolean[] a)
    {
        int index = 0;
        int i;
        for (i = a.length - 1; i > -1; i--)
        {
            if (!a[i])
            {
                index = i;
                break;
            }
        }
        if(i == -1)
            finished = true;
        return index;
    }

    public static void main(String[] args) throws IOException
    {
//      while(true)
//      {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int n = Integer.parseInt(br.readLine());
            String str = br.readLine();
            int len = str.length();
            boolean[] valid = new boolean[n];
            boolean flag = true;

            for (int i = 0; i < str.length() ; i++)
            {
                if (str.charAt(i) != '?')
                    valid[str.charAt(i) - 'a'] = true;
            }

            for (int i = (int)Math.ceil(len / 2); i >= 0 && len > 1;  i--)
            {
//              System.out.println(str);
                if (str.charAt(i) == str.charAt(len - 1 - i))
                {
                    if (str.charAt(i) == '?')
                    {
                        char toReplace = (char) ((int) 'a' + getFFlse(valid));
                        str = replaceIndex(str, i, toReplace);
                        str = replaceIndex(str, len - 1 - i, toReplace);
                        valid[toReplace - 'a'] = true;
                    }
                } else
                {
                    if (str.charAt(i) == '?')
                    {
                        str = replaceIndex(str, i, str.charAt(len - 1 - i));
                    } else if (str.charAt(len - 1 - i) == '?')
                    {
                        str = replaceIndex(str, len - 1 - i, str.charAt(i));

                    } else
                    {
                        flag = false;
                        break;
                    }
                }
            }

            getFFlse(valid);
            if (!finished)
            {
//              System.out.println("not valid");
//              System.out.println(Arrays.toString(valid));
                flag = false;
            }

            if(len == 1 && n == 1)
            {
                str = "a";
                flag = true;
            }
            if (flag)
                System.out.println(str);
            else
                System.out.println("IMPOSSIBLE");
            finished = false;
//      }
    }
}


//Date: Oct 8, 2013
//Time: 11:52:15 PM

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

public class A203 implements Runnable {

	public void solve() throws IOException {
		int x = nextInt();
		int t = nextInt();
		int a = nextInt();
		int b = nextInt();
		int da = nextInt();
		int db = nextInt();

		boolean possible  = false;

		for(int i = 0; i < t; i++)
			for(int j = 0; j < t; j++){
				if(a - (da * i) + b - (db * j) == x)
				{
					possible = true;
					break;
				}
				if(a - (da * i) == x){
					possible = true;
					break;
				}
				if(b - (db * j) == x){
					possible = true;
					break;
				}
			}

		if(possible || x == 0) System.out.println("YES");
		else System.out.println("NO");
	}

	//-----------------------------------------------------------
	public static void main(String[] args) {
		new A203().run();
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			tok = null;
			solve();
			in.close();
		} catch (IOException e) {
			System.exit(0);
		}
	}

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

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

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

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

	BufferedReader in;
	StringTokenizer tok;
}
/**
public class A203 {

}

*/


import java.io.*;
import java.lang.Math;
import java.util.Scanner;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class main
{
        public static Scanner in;
        public static PrintStream out;

		public static long fnk[][];
		public static long tnk[][];

		public static long d10[];
		public static long d8[];

		public static long M = 1000000007;

		static int K;

		public static long _Fnk(int n, int k)
		{
			if (n<2)
			{
				return 0;
			}

			return (2*Tnk(n-1, k)+ 8*Fnk(n-1, k) + 2*Pnk(n-1, k, k)) % M;
		}

		public static long Fnk(int n, int k)
		{
			if (fnk[n][k]==-1)
			{
				fnk[n][k] = _Fnk(n,k);
			}
			return fnk[n][k];
		}

		public static long Tnk(int n, int k)
		{
			if (tnk[n][k]==-1)
			{
				tnk[n][k] = _Tnk(n,k);
			}
			return tnk[n][k];
		}

		public static long Pnk(int n, int r,int k)
		{
			if (n-r<2)
			{
				return 0;
			}

			return D8(r)*Fnk(n-r,k) % M;
		}

		public static long _Tnk(int n, int k)
		{
			if (k<1)
			{
				return 0;
			}

			if (n<1)
			{
				return 0;
			}

			if (n>k)
			{
				return 10*Tnk(n-1, k) % M;
			}

			return (2*D(n-1)+8*Tnk(n-1, k-1)) % M;
		}

		public static long D(int n)
		{
			if (n==0)
			{
				return 1;
			}

			if (d10[n]==-1)
			{
				d10[n] = BigInteger.valueOf(10).modPow(BigInteger.valueOf(n), BigInteger.valueOf(M)).longValue();
			}

			return d10[n];
		}

		public static long D8(int n)
		{
			if (n==0)
			{
				return 1;
			}

			if (d8[n]==-1)
			{
				d8[n] = BigInteger.valueOf(8).modPow(BigInteger.valueOf(n), BigInteger.valueOf(M)).longValue();
			}

			return d8[n];
		}

		public static long F(String s, int k)
		{
			int n = s.length();

			if (n<2)
			{
				return 0;
			}

			long r1,r2=0,r = 0;

			int d = Integer.parseInt(String.valueOf(s.charAt(0)));

			if (d>0)
			{
				r1 = Fnk(n-1, k) % M;
				if (d>4)
				{
					r2 =  (Tnk(n-1, k) + Pnk(n-1, k, k)) % M;
				}

				if (d<5)
				{
					r += d* r1;
				}
				else if (d<8)
				{
					r += (d-1)* r1 + r2;
				}
				else
				{
					r += (d-2)* r1 + 2*r2;
				}
			}

			String s2 = s.substring(1);

			if ((d==4)||(d==7))
			{
				r += (T(s2, k) + P(s2, k, k)) % M;
			}
			else
			{
				r += F(s2, k) % M;
			}

			return r % M;
		}

		public static long T(String s, int k)
		{
			if (k<1)
			{
				return 0;
			}

			int n = s.length();

			if (n==0)
			{
				return 0;
			}

			long r1,r2=0,r = 0;

			int d = Integer.parseInt(String.valueOf(s.charAt(0)));

			if (d>0)
			{
				r1 = Tnk(n-1, k-1) % M;
				if (d>4)
				{
					r2 =  D(n-1);
				}

				if (d<5)
				{
					r += d* r1;
				}
				else if (d<8)
				{
					r += (d-1)* r1 + r2;
				}
				else
				{
					r += (d-2)* r1 + 2*r2;
				}
			}

			String s2 = s.substring(1);

			if ((d==4)||(d==7))
			{
				if (s2.length()==0)
				{
					r+= 1;
				}
				else
				{
					BigInteger b = new BigInteger(s2);
					r += b.add(BigInteger.ONE).mod(BigInteger.valueOf(M)).longValue();
				}
			}
			else
			{
				r += T(s2, k-1);
			}

			return r % M;
		}

		public static long P(String s, int r, int k)
		{
			int n = s.length();

			if (n-r<2)
			{
				return 0;
			}

			if (k==0)
			{
				return 0;
			}

			if (r==0)
			{
				return F(s,k);
			}

			long r1,r2=0,rs = 0;

			int d = Integer.parseInt(String.valueOf(s.charAt(0)));

			if (d>0)
			{
				r1 = Pnk(n-1, r-1, k) % M;

				if (d<5)
				{
					rs += d* r1;
				}
				else if (d<8)
				{
					rs += (d-1)* r1 ;
				}
				else
				{
					rs += (d-2)* r1 ;
				}
			}

			String s2 = s.substring(1);

			if ((d==4)||(d==7))
			{
				rs += 0;
			}
			else
			{
				rs += P(s2, r-1, k);
			}

			return rs % M;
		}

        public static void test()
        {
			String ln;
			do {
				ln = in.nextLine();
			} while (ln.length()==0);

			StringTokenizer st = new StringTokenizer(ln);

             String l,r;
			 l = st.nextToken();
			 r = st.nextToken();

			 BigInteger bl = new BigInteger(l);

			 long s = (M + F(r, K)  - F(bl.subtract(BigInteger.ONE).toString(), K)) % M;

			 out.println(s);

        }

        public static void main(String args[])
        {
                try
                {
                        //in = new Scanner(new File("in.txt"));
                        //out = new PrintStream(new File("out.txt"));
                        in = new Scanner(System.in);
                        out = System.out;
                }
                catch (Exception e)
                {
                        return;
                }

				int t,i,j;

				t = in.nextInt();
				K = in.nextInt();

				fnk = new long[1001][];
				tnk = new long[1001][];
				d8 = new long[1001];
				d10 = new long[1001];

				for (i=0;i<1001;i++)
				{
					fnk[i] = new long[K+1];
					tnk[i] = new long[K+1];

					d8[i] = -1;
					d10[i] = -1;

					for (j=0; j<=K; j++)
					{
						fnk[i][j] = -1;
						tnk[i][j] = -1;
					}
				}

				for (i=0; i<t; i++)
				{
					test();
				}

				//	out.println(T("41883", 3));

        }
}


import java.util.*;
public class B
{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in); in.nextLine();
        System.out.println(Long.parseLong(new StringBuilder(in.nextLine().replaceAll("R","0").replaceAll("B","1")).reverse().toString(),2));
    }
}


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

public class Main{
	static class Point{
		int x; long y;
		Point(int nx, long ny){
			x = nx; y = ny;
		}
	}
	static long mod = (long)(1e9 + 7);
	static int MAXN = (int)(4e5 + 5);
	static long[] dp = new long[MAXN];
	static long[] a;
	static boolean[] v = new boolean[MAXN];
    public static void main(String[] args) throws IOException{
    	In in = new In();
    	in.tok();
    	int n = in.pint(), k = in.pint();
    	a = new long[n];
    	in.tok();
    	for(int i = 0; i < n; i++) {a[i] = -in.pint();}
    	Arrays.sort(a);
    	for(int i = 0; i < n; i++) {a[i] = -a[i];}
    	long ttl = 0;
    	int si = 0;
    	long s = a[0];
    	while(s >= 0 && si < n - 1) {
    		ttl += s;
    		si++;
    		s += a[si];
    	}
    	if(si >= n - 1) {System.out.println(ttl); return;}
    	a[si] = s;
    	int p = 0;
    	int mul = 0;
    	for(int i = n - 1; i >= si; i--) {
    		ttl += a[i] * mul;
    		p++;
    		if(p % (k + 1) == 0) {mul++;}
    	}
    	System.out.println(ttl);
    }
}

class In{
    BufferedReader in;
    StringTokenizer st = new StringTokenizer("");
    public In(){
        in = new BufferedReader(new InputStreamReader(System.in));
    }

    int pint() throws IOException{
        if(st.hasMoreTokens()) {return Integer.parseInt(st.nextToken());}
        else {return Integer.parseInt(in.readLine());}
    }
    double pdbl() throws IOException{
        if(st.hasMoreTokens()) {return Double.parseDouble(st.nextToken());}
        else {return Double.parseDouble(in.readLine());}
    }
    long plng() throws IOException{
        if(st.hasMoreTokens()) {return Long.parseLong(st.nextToken());}
        else {return Long.parseLong(in.readLine());}
    }
    char pchr() throws IOException{
        if(st.hasMoreTokens()) {return st.nextToken().charAt(0);}
        else {return in.readLine().charAt(0);}
    }
    String pstr() throws IOException{
        if(st.hasMoreTokens()) {return st.nextToken();}
        else {return in.readLine();}
    }
    String readLine() throws IOException{
    	return in.readLine();
    }
    boolean ready() throws IOException {return in.ready();}
    void tok() throws IOException{st = new StringTokenizer(in.readLine());}
    void skip() throws IOException{in.readLine();}
}


import java.util.*;

public class Main{
    public static void main( String[] args){
     Scanner sc = new Scanner( System.in);
     int t= sc.nextInt();
     while(t-->0){
         int n = sc.nextInt();
         System.out.println((int)Math.pow(2,n)-1);
     }
    }

}


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

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long c = in.nextLong();

            long sum1 = a + b + c;
            long sum2 = a + a + b + b;
            long sum3 = a + a + c + c;
            long sum4 = b + b + c + c;

            out.println(Math.min(Math.min(Math.min(sum1, sum2), sum3), sum4));
        }

    }

    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 long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public 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.util.Arrays;
import java.io.IOException;
import java.util.Random;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            DLinearCongruentialGenerator solver = new DLinearCongruentialGenerator();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class DLinearCongruentialGenerator {
        public int log(int x, int y) {
            int ans = 0;
            while (y != 0 && y % x == 0) {
                ans++;
                y /= x;
            }
            return ans;
        }

        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            int limit = (int) 2e6;
            IntegerMultiWayStack primeFactors = Factorization.factorizeRangePrime(limit);
            int[] cnts = new int[limit + 1];
            int[] times = new int[limit + 1];
            int[] xs = new int[n];

            in.populate(xs);
            Randomized.shuffle(xs);
            Arrays.sort(xs);
            SequenceUtils.reverse(xs);
            boolean[] retain = new boolean[n];
            for (int i = 0; i < n; i++) {
                int x = xs[i];
                if (cnts[x] == 0) {
                    retain[i] = true;
                    cnts[x] = 1;
                    times[x] = 1;
                    continue;
                }

                for (IntegerIterator iterator = primeFactors.iterator(x - 1); iterator.hasNext(); ) {
                    int p = iterator.next();
                    int log = log(p, x - 1);
                    if (cnts[p] < log) {
                        cnts[p] = log;
                        times[p] = 0;
                    }
                    if (cnts[p] == log) {
                        times[p]++;
                    }
                }
            }

            Modular mod = new Modular(1e9 + 7);
            int prod = 1;
            for (int i = 1; i <= limit; i++) {
                for (int j = 0; j < cnts[i]; j++) {
                    prod = mod.mul(prod, i);
                }
            }

            for (int i = 0; i < n; i++) {
                int x = xs[i];
                boolean unique = false;
                if (retain[i]) {
                    if (cnts[x] == 1 && times[x] == 1) {
                        unique = true;
                    }
                } else {
                    for (IntegerIterator iterator = primeFactors.iterator(x - 1); iterator.hasNext(); ) {
                        int p = iterator.next();
                        int log = log(p, x - 1);
                        if (cnts[p] == log && times[p] == 1) {
                            unique = true;
                        }
                    }
                }
                if (!unique) {
                    prod = mod.plus(prod, 1);
                    break;
                }
            }

            out.println(prod);
        }

    }

    static class Modular {
        int m;

        public Modular(int m) {
            this.m = m;
        }

        public Modular(long m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public Modular(double m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public int valueOf(int x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return x;
        }

        public int valueOf(long x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return (int) x;
        }

        public int mul(int x, int y) {
            return valueOf((long) x * y);
        }

        public int plus(int x, int y) {
            return valueOf(x + y);
        }

        public String toString() {
            return "mod " + m;
        }

    }

    static class DigitUtils {
        private DigitUtils() {
        }

        public static boolean isMultiplicationOverflow(long a, long b, long limit) {
            if (limit < 0) {
                limit = -limit;
            }
            if (a < 0) {
                a = -a;
            }
            if (b < 0) {
                b = -b;
            }
            if (a == 0 || b == 0) {
                return false;
            }
            //a * b > limit => a > limit / b
            return a > limit / b;
        }

    }

    static class RandomWrapper {
        private Random random;
        public static RandomWrapper INSTANCE = new RandomWrapper(new Random());

        public RandomWrapper() {
            this(new Random());
        }

        public RandomWrapper(Random random) {
            this.random = random;
        }

        public int nextInt(int l, int r) {
            return random.nextInt(r - l + 1) + l;
        }

    }

    static class Randomized {
        public static void shuffle(int[] data) {
            shuffle(data, 0, data.length - 1);
        }

        public static void shuffle(int[] data, int from, int to) {
            to--;
            for (int i = from; i <= to; i++) {
                int s = nextInt(i, to);
                int tmp = data[i];
                data[i] = data[s];
                data[s] = tmp;
            }
        }

        public static int nextInt(int l, int r) {
            return RandomWrapper.INSTANCE.nextInt(l, r);
        }

    }

    static class MinimumNumberWithMaximumFactors {
        private static int[] primes = new int[]{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

        public static long[] maximumPrimeFactor(long n) {
            long[] ans = new long[2];
            ans[0] = 1;
            for (int i = 0; i < primes.length; i++) {
                if (DigitUtils.isMultiplicationOverflow(ans[0], primes[i], n)) {
                    break;
                }
                ans[0] *= primes[i];
                ans[1]++;
            }
            return ans;
        }

    }

    static class IntegerMultiWayStack {
        private int[] values;
        private int[] next;
        private int[] heads;
        private int alloc;
        private int stackNum;

        public IntegerIterator iterator(final int queue) {
            return new IntegerIterator() {
                int ele = heads[queue];

                public boolean hasNext() {
                    return ele != 0;
                }

                public int next() {
                    int ans = values[ele];
                    ele = next[ele];
                    return ans;
                }
            };
        }

        private void doubleCapacity() {
            int newSize = Math.max(next.length + 10, next.length * 2);
            next = Arrays.copyOf(next, newSize);
            values = Arrays.copyOf(values, newSize);
        }

        public void alloc() {
            alloc++;
            if (alloc >= next.length) {
                doubleCapacity();
            }
            next[alloc] = 0;
        }

        public boolean isEmpty(int qId) {
            return heads[qId] == 0;
        }

        public IntegerMultiWayStack(int qNum, int totalCapacity) {
            values = new int[totalCapacity + 1];
            next = new int[totalCapacity + 1];
            heads = new int[qNum];
            stackNum = qNum;
        }

        public void addLast(int qId, int x) {
            alloc();
            values[alloc] = x;
            next[alloc] = heads[qId];
            heads[qId] = alloc;
        }

        public String toString() {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < stackNum; i++) {
                if (isEmpty(i)) {
                    continue;
                }
                builder.append(i).append(": ");
                for (IntegerIterator iterator = iterator(i); iterator.hasNext(); ) {
                    builder.append(iterator.next()).append(",");
                }
                if (builder.charAt(builder.length() - 1) == ',') {
                    builder.setLength(builder.length() - 1);
                }
                builder.append('\n');
            }
            return builder.toString();
        }

    }

    static class Factorization {
        public static IntegerMultiWayStack factorizeRangePrime(int n) {
            int maxFactorCnt = (int) MinimumNumberWithMaximumFactors.maximumPrimeFactor(n)[1];
            IntegerMultiWayStack stack = new IntegerMultiWayStack(n + 1, n * maxFactorCnt);
            boolean[] isComp = new boolean[n + 1];
            for (int i = 2; i <= n; i++) {
                if (isComp[i]) {
                    continue;
                }
                for (int j = i; j <= n; j += i) {
                    isComp[j] = true;
                    stack.addLast(j, i);
                }
            }
            return stack;
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }

    static class SequenceUtils {
        public static void swap(int[] data, int i, int j) {
            int tmp = data[i];
            data[i] = data[j];
            data[j] = tmp;
        }

        public static void reverse(int[] data, int l, int r) {
            while (l < r) {
                swap(data, l, r);
                l++;
                r--;
            }
        }

        public static void reverse(int[] data) {
            reverse(data, 0, data.length - 1);
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        public void populate(int[] data) {
            for (int i = 0; i < data.length; i++) {
                data[i] = readInt();
            }
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

    }

    static interface IntegerIterator {
        boolean hasNext();

        int next();

    }
}


import com.sun.org.apache.bcel.internal.generic.AALOAD;
import java.io.*;
import java.util.*;
import java.math.BigInteger.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.util.Arrays.*;
import java.util.logging.Level;
import java.util.logging.Logger;

// https://netbeans.org/kb/73/java/editor-codereference_ru.html#display
//<editor-fold defaultstate="collapsed" desc="Main">
public class Main {

    private void run() {
        Locale.setDefault(Locale.US);
        boolean oj = true;
        try {
            oj = System.getProperty("MYLOCAL") == null;
        } catch (Exception e) {
        }

        if (oj) {
            sc = new FastScanner(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
        } else {
            try {
                sc = new FastScanner(new FileReader("input.txt"));
                out = new PrintWriter(new FileWriter("output.txt"));
            } catch (IOException e) {
                MLE();
            }
        }
        Solver s = new Solver();
        s.sc = sc;
        s.out = out;
        s.solve();
        if (!oj) {
            err.println("Time: " + (System.currentTimeMillis() - timeBegin) / 1e3);
            err.printf("Mem: %d\n", (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) >> 20);
        }
        out.flush();
    }

    private void show(int[] arr) {
        for (int v : arr) {
            err.print(" " + v);
        }
        err.println();
    }

    public static void MLE() {
        int[][] arr = new int[1024 * 1024][];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = new int[1024 * 1024];
        }
    }

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

    long timeBegin = System.currentTimeMillis();
    FastScanner sc;
    PrintWriter out;
    PrintStream err = System.err;
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc="FastScanner">
class FastScanner {

    BufferedReader br;
    StringTokenizer st;

    FastScanner(InputStreamReader reader) {
        br = new BufferedReader(reader);
        st = new StringTokenizer("");
    }

    String next() {
        while (!st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException ex) {
                Main.MLE();
            }
        }
        return st.nextToken();
    }

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

    long nextLong() {
        return Long.parseLong(next());
    }
}
//</editor-fold>

class Node{
    static Random rnd = new Random();
//    {
//        for (int i = 0; i < 10; i++) {
//            System.err.println(rnd.nextInt());
//        }
//    }
    int val, sz, prior;
    Node l, r;

    Node( int val ){
        this.val = val;
        sz = 1;
        prior = rnd.nextInt();
        l = r = null;
    }

    @Override
    public String toString() {
        return val + "";
    }
}

class Solver {

    FastScanner sc;
    PrintWriter out;
    PrintStream err = System.err;

    Random rnd = new  Random();

    int getCnt( Node t ){
        return t==null? 0 : t.sz;
    }

    void upd(Node t) {
        t.sz = 1 + getCnt(t.l) + getCnt(t.r);
    }

    Node firstElement;
    Node pollFirst(Node t){
        Node root = t;
        Node parent = null;
        while( t.l != null ){
            --t.sz;
            parent = t;
            t = t.l;
        }

        if( parent == null ){
            root = t.r;
        }
        else{
            parent.l = t.r;
            upd( parent );
        }
        firstElement = t;
        firstElement.l = firstElement.r = null;
        firstElement.sz = 1;
        return root;
    }

    Node insert( Node t, Node it, int key, int add ){
        if( t == null ){
            return it;
        }
        int curKey = add + 1 + getCnt(t.l);
        if( t.prior > it.prior ){
            if (curKey < key)
                t.r = insert( t.r, it, key, curKey );
            else
                t.l = insert( t.l, it, key, add    );
            upd( t );
            return t;
        }
        else{
            split( t, key-1, add );
            it.l = l2;
            it.r = r2;
            upd( it );
            return it;
        }
    }

    void split( Node t, int key, int add ){
        curRec = 0;
        split2(t, key, add);
        maxRec = max( maxRec, curRec );
        if( 45 <= curRec ){
            maxRec = 0;
Main.MLE();
            err.println( "rebuilding..." );
            l2 = rebuild(l2);
            r2 = rebuild(r2);
        }
    }

    Node rebuild(Node t){
        szArr = 0;
        dfs( t );
        t = build(0, szArr-1);
        return t;
    }

    Node l2, r2;
    void split2( Node t, int key, int add ){
        ++curRec;
        if( t == null ){
            l2 = r2 = null;
            return;
        }

        int curKey = add + 1 + getCnt(t.l);
        if( curKey <= key ){
            split2(t.r, key, curKey);
            t.r = l2;
            l2 = t;
        }
        else{
            split2(t.l, key, add);
            t.l = r2;
            r2 = t;
        }
        upd(t);
    }

    int szArr;
    Node[] arr;
    void dfs( Node t ){
        if( t == null ) return;
        dfs( t.l );
        arr[szArr++] = t;
        dfs( t.r );
    }

    void show( Node t, int cnt ){
        if( t == null ) return;

        String s = "  ";
        for( int i = 0; i < cnt; ++i )  out.print(s);
        out.println(t.val +" "+ t.prior);

        if( t.l != null ){
            for( int i = 0; i < cnt; ++i )  out.print(s);
            out.println("l*");
            show( t.l, cnt+1 );
        }

        if( t.r != null ){
            for( int i = 0; i < cnt; ++i )  out.print(s);
            out.println("r*");
            show( t.r, cnt+1 );
        }
    }

    Node build( int l, int r ){
        if(!( l <= r )){
            return null;
        }
        else{
            int tm = (l + r) / 2;
            Node t = arr[tm];
            t.l = build(  l, tm-1 );
            t.r = build( tm+1, r );
            upd( t );
            return t;
        }
    }

    int curRec, maxRec = 0;

    void solve(){
        //deb();
        int n, q;
        Node t;

        n = sc.nextInt();
        q = sc.nextInt();

        arr = new Node[n];
        for (int i = 0; i < n; i++) arr[i] = new Node(-1);
        t = build( 0, n-1 );

        int[] vals = new int[q];
        int[] poss = new int[q];
        for (int iter = 0; iter < q; iter++) {
            vals[iter] = sc.nextInt();
            poss[iter] = sc.nextInt();
        }

        boolean[] haveVal = new boolean[n+1];
        haveVal[0] = true;

        for( int iter = q-1; 0 <= iter; --iter ){
            int val = vals[iter];
            int pos = poss[iter];

            t = pollFirst(t);
            if( getCnt(t) != n-1 ) Main.MLE();
            if( firstElement.val == -1 ){
                if( haveVal[val] ){
                    out.println("-1");
                    return;
                }
                firstElement.val = val;
            }
            else if( firstElement.val == val );
            else{
                out.println("-1");
                return;
            }

            haveVal[val] = true;
            t = insert( t, firstElement, pos, 0 );
        }

        err.println( "maxRec: " + maxRec );

        szArr = 0; dfs( t );

        int ptr = 1;
        for( int i = 0; i < n; ++i )
            if( arr[i].val == -1 ){
                while( haveVal[ptr] ) ++ptr;
                arr[i].val = ptr++;
            }

        for( Node v : arr )
            out.print( " " + v.val );
        out.println();
    }
}


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

public class CopyOfPermutations {

	final String filename = new String("Permutations").toLowerCase();

	void solve() throws Exception {
		String s = in.readLine();
		int n = s.length();
		int[] cnt = new int[10];
		for (int i = 0; i < n; i++) {
			cnt[(int) (s.charAt(i) - '0')]++;
		}

		int bestAns = 0;
		int bestZeros = 0;
		int bestFirst = 0;

		for (int zeros = 0; zeros <= cnt[0]; zeros++) {
			for (int first = 1; first < 10; first++) {
				int[] cnt1 = cnt.clone();
				int[] cnt2 = cnt.clone();
				cnt1[0] -= zeros;
				cnt2[0] -= zeros;
				int curAns = zeros;
				boolean ok = false;
				if (cnt1[first] > 0 && cnt2[10 - first] > 0) {
					cnt1[first]--;
					cnt2[10 - first]--;
					curAns++;

					ok = true;
					for (int i = 0; i < 10; i++) {
						curAns += Math.min(cnt1[i], cnt2[9 - i]);
					}
				}
				if (curAns > bestAns) {
					bestAns = curAns;
					bestZeros = zeros;
					if (ok)
						bestFirst = first;
					else
						bestFirst = -1;
				}
			}
		}

		if (bestAns == 0) {
			out.println(s);
			out.println(s);
		} else {
			ArrayList<Integer> ans1 = new ArrayList<Integer>();
			ArrayList<Integer> ans2 = new ArrayList<Integer>();
			int[] cnt1 = cnt.clone();
			int[] cnt2 = cnt.clone();
			for (int i = 0; i < bestZeros; i++) {
				ans1.add(0);
				ans2.add(0);
			}
			cnt1[0] -= bestZeros;
			cnt2[0] -= bestZeros;

			if (bestFirst != -1) {
				ans1.add(bestFirst);
				ans2.add(10 - bestFirst);
				cnt1[bestFirst]--;
				cnt2[10 - bestFirst]--;

				for (int i = 0; i < 10; i++) {
					int j = 9 - i;
					while (cnt1[i] > 0 && cnt2[j] > 0) {
						ans1.add(i);
						ans2.add(j);
						cnt1[i]--;
						cnt2[j]--;
					}
				}
			}
			for (int i = 0; i < 10; i++) {
				while (cnt1[i] > 0) {
					ans1.add(i);
					cnt1[i]--;
				}
				while (cnt2[i] > 0) {
					ans2.add(i);
					cnt2[i]--;
				}
			}

			Collections.reverse(ans1);
			Collections.reverse(ans2);

			for (int i : ans1) {
				out.print(i);
			}
			out.println();
			for (int i : ans2) {
				out.print(i);
			}
		}
	}

	void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			// in = new BufferedReader(new FileReader("input.txt"));
			// out = new PrintWriter("output.txt");

			solve();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

	String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

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

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

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

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

}


//package round76;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class D2 {
	Scanner in;
	String INPUT = "";
	PrintWriter out;

	static int MOD = 1000000007;

	void solve()
	{
		int L = ni();
		int R = ni();
		String[] t = {"  ", " B", " R", " W", " Y", "BW", "BY", "RW", "RY", "WB", "WR", "YB", "YR"};
		int m = t.length;
		int[][] M = new int[m+1][m+1];
		for(int i = 0;i < m;i++){
			for(int j = 0;j < m;j++){
				if(t[i].charAt(1) == t[j].charAt(0)){
					M[j][i] = 1;
				}
			}
		}
		M[0][0] = 0;
		M[10][5] = 0;
		M[9][7] = 0;
		for(int i = 0;i <= m;i++) {
			M[m][i] = 1;
		}

		int[][][] A = generateP2(M, 30);

		int[] v = new int[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		int[] gp1 = pow(A, v, R+1);
		int[] gp2 = pow(A, v, L-1+1);

		int[] gpq1 = pow(A, v, (R+1)/2+1);
		int[] gpq2 = pow(A, v, L/2+1);

		long i2 = inv(2, MOD);

		long sum = 0;
		sum += (gp1[m]-gp2[m]-gpq1[m]+gpq2[m])*i2+(gpq1[m]-gpq2[m]);
		sum %= MOD;
		out.println((sum+MOD)%MOD);
	}

	public static long inv(long a, int p)
	{
		long ret = 1;
		long mul = a;
		for(long n = p-2;n > 0;n >>>= 1){
			if((n&1)==1)ret = ret * mul % p;
			mul = mul * mul % p;
		}
		return ret;
	}

	public static int[][][] generateP2(int[][] A, int n)
	{
		int[][][] ret = new int[n+1][][];
		ret[0] = A;
		for(int i = 1;i <= n;i++)ret[i] = p2(ret[i-1]);
		return ret;
	}

	public static int[] pow(int[][][] A, int[] v, long e)
	{
		for(int i = 0;e > 0;e>>>=1,i++) {
			if((e&1)==1)v = mul(A[i], v);
		}
		return v;
	}

	public static int[][] p2(int[][] A)
	{
		int n = A.length;
		int[][] C = new int[n][n];
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				long sum = 0;
				for(int k = 0;k < n;k++){
					sum += (long)A[i][k] * A[k][j];
					sum %= MOD;
				}
				C[i][j] = (int)sum;
			}
		}
		return C;
	}

	public static int[] mul(int[][] A, int[] v)
	{
		int m = A.length;
		int n = v.length;
		int[] w = new int[m];
		for(int i = 0;i < m;i++){
			long sum = 0;
			for(int k = 0;k < n;k++){
				sum += (long)A[i][k] * v[k];
				sum %= MOD;
			}
			w[i] = (int)sum;
		}
		return w;
	}

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

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

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

	int ni() { return Integer.parseInt(in.next()); }
	long nl() { return Long.parseLong(in.next()); }
	double nd() { return Double.parseDouble(in.next()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


//package com.company;

//import java.io.File;
//import java.io.FileNotFoundException;
//import java.nio.charset.StandardCharsets;
import java.util.*;
import java.io.*;

 public class Main {

    public static void main(String[] args) {

        //File file = new File("/Users/ahmed/Development/CompetitiveProgramming\ git java/src/com/company/in.txt");
        //Scanner scanner = new Scanner(file);
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] =  in.nextInt();
        }

        System.out.print(loopthough(n,nums));
    }

     private static String loopthough(int n, int[] nums) {
         String result = "NO";
         for (int i = 0; i < n ; i++) {
             for (int j = 0; j < n && j!=i ; j++) {
                 for (int k = 0; k < n && k!=j; k++) {
                     if (i == j || j==k || k==i)// same index
                         continue;
                     int a = nums[i];
                     int b = nums[j];
                     int c = nums[k];
                     if (a+b>c && a+c>b && b+c>a) {

                         return "YES";
                     }
                 }
             }
         }
         return result;
     }
 }


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

public class ForProblems {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    public static void main(String[] args){

        new ForProblems().run();
    }

    public void run() {

        try {
            long timeBegin = System.currentTimeMillis();
            Locale.setDefault(Locale.US);

            init();
            solve();

            out.close();

            long timeEnd = System.currentTimeMillis();
            System.err.println("Time = " + (timeEnd - timeBegin));
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    void init() throws FileNotFoundException {

        Locale.setDefault(Locale.US);

        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    Random rnd = new Random();

    void solve() throws IOException {

        int r = readInt();
        int c = readInt();
        int n = readInt();
        int k = readInt();
        int[][] a = new int[r][c];
        for (int i = 0; i < n; ++i) {
            int b = readInt() - 1;
            int d = readInt() - 1;
            a[b][d] = 1;
        }

        int ans = 0;
        for (int i = 0; i < r; ++i) {
            for (int j = 0; j < c; ++j) {
                int sum = a[i][j];
                if (sum >= k)
                    ++ans;
                int[] prevSum = new int[c];
                prevSum[j] = a[i][j];
                for (int q = i; q < r; ++q) {
                    for (int t = j; t < c; ++t) {
                        if (q == i && t == j)
                            continue;
                        sum += prevSum[t] + a[q][t];
                        prevSum[t] += a[q][t];
                        if (sum >= k)
                            ++ans;
                    }
                    sum = 0;
                }
            }
        }

        out.print(ans);
    }

    String readString() throws IOException {
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

public class Main {

	InputStream is;
	PrintWriter out;
	String INPUT = "";

	private static final long M = 1000000007L;

	List<Integer> g[];

	int p[];
	int nextTo[];
	int size[];

	int dp[][];

	void solve() {
		StringBuffer sb = new StringBuffer();
		int T = ni();
		while (T-- > 0) {
			int N = ni();
			int M = ni();
			int A = ni();
			int B = ni();
			p = new int[N + 1];
			nextTo = new int[N + 1];
			size = new int[N + 1];
			Arrays.fill(size, 1);

			int edges[][] = na(M, 2);

			for (int e[] : edges) {
				if (e[0] == A)
					nextTo[e[1]] |= 1;
				else if (e[0] == B)
					nextTo[e[1]] |= 2;

				if (e[1] == A)
					nextTo[e[0]] |= 1;
				else if (e[1] == B)
					nextTo[e[0]] |= 2;
			}
			for (int e[] : edges) {
				if (e[0] == A || e[0] == B || e[1] == A || e[1] == B)
					continue;
				connect(e[0], e[1]);
			}

			long cnt[] = new long[4];
			for (int i = 1; i <= N; i++) {
				if (p[i] == 0 && i != A && i != B)
					cnt[nextTo[i]] += size[i];
			}
			sb.append(cnt[1] * cnt[2]).append(System.lineSeparator());
		}

		out.print(sb);

	}

	private void connect(int u, int v) {
		int u0 = find(u);
		int v0 = find(v);
		if (u0 == v0)
			return;
		p[u0] = v0;
		size[v0] += size[u0];
		nextTo[v0] |= nextTo[u0];
	}

	private int find(int x) {
		if (p[x] == 0)
			return x;
		else
			return p[x] = find(p[x]);
	}

	private List<Integer>[] getG(int N, int M) {
		List<Integer>[] ret = new List[N];
		for (int i = 0; i < N; i++)
			ret[i] = new ArrayList<Integer>();
		for (int i = 0; i < M; i++) {
			int u = ni() - 1;
			int v = ni() - 1;
			ret[u].add(v);
		}
		return ret;
	}

	private long gcd(long a, long b) {
		while (a != 0) {
			long tmp = b % a;
			b = a;
			a = tmp;
		}
		return b;
	}

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

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

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

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

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

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

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

	private char nc() {
		return (char) skip();
	}

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

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

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

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

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

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

	private Integer[][] na2(int n, int m) {
		Integer[][] a = new Integer[n][];
		for (int i = 0; i < n; i++)
			a[i] = na2(m);
		return a;
	}

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

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

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

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

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


import java.util.*;
public class Main {
public static void main(String [] args){
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int mod = 1000000007;
        int red[]=new int[n+1];
        int blue[]=new int[n+1];
        for(int i=1;i<=n;i++){
        	if((i&1)==1){
        	blue[i]=red[i-1]+blue[i-1]+1;
        	while(blue[i] >= mod)blue[i] -= mod;
        	red[i]=red[i-1];
        	}
        	else{
        	red[i]=red[i-1]+blue[i-1]+1;
        	while(red[i] >= mod)red[i] -= mod;
        	blue[i]=blue[i-1];
        	}
        }
        //for(int i=1;i<=n;i++)System.out.println(red[i]+" "+blue[i]);
        System.out.print((red[n]+blue[n])%mod);
}
}


import java.util.*;
import java.math.*;
// Itreator for map  for(Map.Entry ent :mp.entrySet())

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n, s1 = 0, s2 = 0;
        n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            s1 += x;
        }
        for (int i = 0; i < n; i++) {
            int y = sc.nextInt();
            s2 += y;
        }

        if (s1 >= s2) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Egor Kulikov (egor@egork.net)
 */
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);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	long[] power;

	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int count = in.readInt();
		int[] treeIndex = new int[count];
		int[] vertex = new int[count];
		char[] label = new char[count];
		for (int i = 0; i < count; i++) {
			treeIndex[i] = in.readInt() - 1;
			vertex[i] = in.readInt() - 1;
			label[i] = in.readCharacter();
		}
		power = new long[count + 1];
		power[0] = 1;
		for (int i = 1; i <= count; i++) {
			power[i] = power[i - 1] * 43;
		}
		int firstCount = 0;
		int secondCount = 0;
		for (int i : treeIndex) {
			if (i == 0)
				firstCount++;
			else
				secondCount++;
		}
		long[] hashFirst = new long[firstCount + 1];
		int[] lengthFirst = new int[firstCount + 1];
		long[] hashSecond = new long[secondCount + 1];
		int[] lengthSecond = new int[secondCount + 1];
		int[] parent = new int[secondCount + 1];
		int maxFirstDepth = 0;
		int firstIndex = 0;
		int secondIndex = 0;
		Hash hash = new Hash();
		for (int i = 0; i < count; i++) {
			if (treeIndex[i] == 0) {
				firstIndex++;
				maxFirstDepth = Math.max(maxFirstDepth, lengthFirst[firstIndex] = lengthFirst[vertex[i]] + 1);
				hashFirst[firstIndex] = hashFirst[vertex[i]] + power[lengthFirst[vertex[i]]] * label[i];
				hash.add(hashFirst[firstIndex]);
			} else {
				secondIndex++;
				lengthSecond[secondIndex] = lengthSecond[vertex[i]] + 1;
				parent[secondIndex] = vertex[i];
				hashSecond[secondIndex] = hashSecond[vertex[i]] * 43 + label[i];
			}
		}
		firstIndex = 0;
		secondIndex = 0;
		long answer = 1;
		for (int i = 0; i < count; i++) {
			if (treeIndex[i] == 0) {
				firstIndex++;
				answer += hash.addFirstGetSecond(hashFirst[firstIndex]);
			} else {
				secondIndex++;
				answer++;
				int current = secondIndex;
				int curDepth = 0;
				do {
					current = parent[current];
					long curHash = hashSecond[secondIndex] - hashSecond[current] * power[lengthSecond[secondIndex] - lengthSecond[current]];
					answer += hash.addSecondGetFirst(curHash);
					curDepth++;
				} while (current != 0 && curDepth < maxFirstDepth);
			}
			out.printLine(answer);
		}
	}
}

class Hash {
	int size = 100003;
	int shift = 30001;
	boolean[] occupied = new boolean[size];
	long[] key = new long[size];
	int[] firstValue = new int[size];
	int[] secondValue = new int[size];

	void add(long key) {
		int index = (int) (key % size);
		if (index < 0)
			index += size;
		while (occupied[index] && this.key[index] != key) {
			index += shift;
			if (index >= size)
				index -= size;
		}
		occupied[index] = true;
		this.key[index] = key;
	}

	int addFirstGetSecond(long key) {
		int index = (int) (key % size);
		if (index < 0)
			index += size;
		while (occupied[index] && this.key[index] != key) {
			index += shift;
			if (index >= size)
				index -= size;
		}
		if (!occupied[index])
			return 0;
		firstValue[index]++;
		return secondValue[index];
	}

	int addSecondGetFirst(long key) {
		int index = (int) (key % size);
		if (index < 0)
			index += size;
		while (occupied[index] && this.key[index] != key) {
			index += shift;
			if (index >= size)
				index -= size;
		}
		if (!occupied[index])
			return 0;
		secondValue[index]++;
		return firstValue[index];
	}
}

class InputReader {

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

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

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

	public int 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 static boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public char readCharacter() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		return (char) c;
	}

	}

class OutputWriter {
	private final PrintWriter writer;

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

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

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

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

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

	}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        F solver = new F();
        solver.solve(1, in, out);
        out.close();
    }

    static class F {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni(), k = in.ni(), l = in.ni();
            int mod = 998244353;
            long[] invs = IntegerUtils.invs(2 * n + 3, mod);
            long[][] p = new long[2 * n + 1][n + 1];
            p[0][1] = 1; // first is always started
            for (int i = 1; i < 2 * n; i++) {
                int prevMaxRunning = Math.min(2 * n - i, i); // how many intervals max were running (covering)
                int maxRunning = Math.min(2 * n - i - 1, i + 1); // how many intervals max can be running
                for (int j = 0; j <= prevMaxRunning; j++) {
                    if (p[i - 1][j] != 0) {
                        if (j > 0) {
                            p[i][j - 1] = (p[i][j - 1] + p[i - 1][j] * j % mod * invs[2 * n - i] % mod) % mod; // close an interval
                        }
                        if (j < maxRunning) {
                            p[i][j + 1] = (p[i][j + 1] + p[i - 1][j] * (2 * n - i - j) % mod * invs[2 * n - i] % mod) % mod; // start a new interval
                        }
                    }
                }
            }
            long ans = 0;
            for (int i = 0; i < 2 * n; i++) {
                for (int j = k; j <= n; j++) {
                    if (p[i][j] == 0)
                        continue;
                    ans = (ans + p[i][j]) % mod;
                }
            }
            ans = ans * l % mod * invs[2 * n + 1] % mod;
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

        public int ni() {
            return Integer.parseInt(ns());
        }

    }

    static class IntegerUtils {
        public static long[] invs(int n, long p) {
            long[] res = new long[n];
            res[1] = 1;
            for (int i = 2; i < n; i++) {
                res[i] = (p - (p / i) * res[(int) (p % i)] % p) % p;
            }
            return res;
        }

    }
}


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

/*
TASK: CFA
LANG: JAVA
 */
public class CFA {
    static int c , v0 , v1 , a , l;

    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        c = in.nextInt();
        v0 = in.nextInt();
        v1 = in.nextInt();
        a = in.nextInt();
        l = in.nextInt();
        int cur = 0;
        for(int i = 1;i < 10000; i++){
            cur -= l;
            cur = Math.max(cur , 0);
            cur += v0;
            v0 += a;
            v0 = Math.min(v0 , v1);
            if(cur >= c){
                System.out.println(i);
                return;
            }
        }
    }

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

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

        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++];
        }

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

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

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

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

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

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

        public String nextLine() {
            int c = read();
            while (isEndline(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndline(c));
            return res.toString();
        }
    }
}


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

public class ProblemD {
    BufferedReader rd;
    long m;

    ProblemD() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        long[] a = longarr();
        long n = a[0];
        long k = a[1];
        long l = a[2];
        m = a[3];

        long max = 1L<<Math.min(l,62);
        if(k>=max) {
            out(0);
        } else {
            long[][] first = new long[][] { { 1, 1 }, { 1, 0 } };
            long[][] res = pow(first,n+1);
            long p = res[0][0];
            long q = pow(2,n);
            long r = sub(q,p,m);

            long u = 1;
            long g = 0;
            long s = 1L%m;
            while(g < l) {
                if(g < 61 && ((k&u) > 0)) {
                    s *= r;
                } else {
                    s *= p;
                }
                s %= m;
                u*=2;
                g++;
            }
            out(s);
        }
    }

    private long sub(long a, long b, long c) {
        return (a+c-(b%c))%c;
    }

    public long pow(long a, long b) {
        if(b == 0) {
            return 1;
        }
        if(b == 1) {
            return a%m;
        }
        long c = pow(a,b/2);
        c = c*c;
        c %= m;
        if(b%2==1) {
            c *= a;
            c %= m;
        }
        return c;
    }

    public long[][] mul(long[][] a, long[][] b) {
        long[][] c = new long[2][2];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                long s = 0;
                for (int k = 0; k < 2; k++) {
                    s += (a[i][k] * b[k][j]) % m;
                    s %= m;
                }
                c[i][j] = s;
            }
        }
        return c;
    }

    private long[][] pow(long[][] a, long b) {
        if(b == 1) {
            return a;
        }
        if(b == 2) {
            return mul(a,a);
        }
        long[][] c = pow(a,b/2);
        c = mul(c,c);
        if(b%2==1) {
            c = mul(c,a);
        }
        return c;
    }

    private long[] longarr() throws IOException {
        return longarr(rd.readLine());
    }

    private long[] longarr(String s) {
        String[] q = split(s);
        int n = q.length;
        long[] a = new long[n];
        for(int i=0;i<n;i++) {
            a[i] = Long.parseLong(q[i]);
        }
        return a;
    }

    public String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

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


import java.util.*;
public class dance {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
      Scanner sc = new Scanner (System .in);
      int n = sc.nextInt();
      int count = n;
     for (int i = 1; i < n; i++) {
		count++;
		count+=((i+1)*(n-i-1));
	}
      System.out.println(count);

	}

}