import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;

public class E {
    static int[] A;
    static int inf = (int) 2e9;
    static int[] s;
    static int[] p;
    static int indexS = -1;
    static int indexP = -1;

    public static boolean collapse(int x) {
        p[++indexP] = x;
        while (indexP != -1) {
            if (indexS == -1)
                return false;
            int y = p[indexP];
            int z = s[indexS--];
            if (-A[z] != y) {
                A[z] *= -1;
                p[++indexP] = A[z];
            } else
                --indexP;
        }
        return true;
    }

    public static boolean solve() {
        for (int i = 0; i < A.length; i++)
            if (A[i] > 0)
                s[++indexS] = i;
            else if (!collapse(A[i]))
                return false;
        return true;
    }

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.readInt();
        A = new int[n + 2];
        A[0] = inf;
        A[n + 1] = -inf;
        s = new int[n + 2];
        p = new int[n + 2];
        for (int i = 0; i < n; i++)
            A[i + 1] = in.readInt();
        int k = in.readInt();
        for (int i = 0; i < k; i++)
            A[in.readInt()] *= -1;
        if (solve()) {
            out.println("YES");
            for (int i = 1; i <= n; i++)
                out.print(A[i] + " ");
            out.println();
        } else
            out.println("NO");
        out.flush();
        out.close();
    }
}

class InputReader {

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

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

    private 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 long readLong() {
        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 String readString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

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

    private String readLine0() {
        StringBuffer buf = new StringBuffer();
        int c = read();
        while (c != '\n' && c != -1) {
            buf.appendCodePoint(c);
            c = read();
        }
        return buf.toString();
    }

    public String readLine() {
        String s = readLine0();
        while (s.trim().length() == 0)
            s = readLine0();
        return s;
    }

    public String readLine(boolean ignoreEmptyLines) {
        if (ignoreEmptyLines)
            return readLine();
        else
            return readLine0();
    }

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

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


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

   private void solve() throws IOException {
      int n = ni();
      int p[] = nia(n);
      int t = ni();
      int q[] = niam1(t);
      boolean sgn[] = new boolean[n];
      for (Integer i : q) {
         sgn[i] = true;
      }
      int stack[] = new int[n];
      int tos = 0;

      for (int i = n - 1; i >= 0; --i) {
         int brt = p[i];
         if (tos > 0 && p[stack[tos - 1]] == brt && !sgn[i])
            --tos;
         else {
            stack[tos++] = i;
            sgn[i] = true;
         }
      }

      if (tos != 0)
         prln("NO");
      else {
         prln("YES");
         for (int i = 0; i < n; ++i) {
            if (sgn[i])
               pr("-" + p[i] + " ");
            else
               pr(p[i] + " ");
         }
      }
   }

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

   public void run() {
      try {
         if (isFileIO) {
            pw = new PrintWriter(new File("output.out"));
            br = new BufferedReader(new FileReader("input.in"));
         } else {
            pw = new PrintWriter(System.out);
            br = new BufferedReader(new InputStreamReader(System.in));
         }
         solve();
         pw.close();
         br.close();
      } catch (IOException e) {
         System.err.println("IO Error");
      }
   }

   private int[] nia(int n) throws IOException {
      int arr[] = new int[n];
      for (int i = 0; i < n; ++i)
         arr[i] = Integer.parseInt(nextToken());
      return arr;
   }

   private int[] niam1(int n) throws IOException {
      int arr[] = new int[n];
      for (int i = 0; i < n; ++i)
         arr[i] = Integer.parseInt(nextToken()) - 1;
      return arr;
   }

   private long[] nla(int n) throws IOException {
      long arr[] = new long[n];
      for (int i = 0; i < n; ++i)
         arr[i] = Long.parseLong(nextToken());
      return arr;
   }

   private void pr(Object o) {
      pw.print(o);
   }

   private void prln(Object o) {
      pw.println(o);
   }

   private void prln() {
      pw.println();
   }

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

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

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

   private String nextToken() throws IOException {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
         tokenizer = new StringTokenizer(br.readLine());
      }

      return tokenizer.nextToken();
   }

   // private void qsort(int a[]) {
   // Random rand = new Random(271828182l);
   // qsort(a, 0, a.length, rand);
   // }
   //
   // private void qsort(int a[], int l, int r, Random rand) {
   // if (r - l <= 1)
   // return;
   //
   // if (r - l == 2) {
   // if (a[r - 1] < a[l]) {
   // int t = a[r - 1];
   // a[r - 1] = a[l];
   // a[l] = t;
   // }
   //
   // return;
   // }
   //
   // int x = a[rand.nextInt(r - l) + l];
   // int i = l, j = r - 1;
   // while (i < j) {
   // while (a[i] < x)
   // ++i;
   // while (a[j] > x)
   // --j;
   // if (i < j) {
   // int t = a[i];
   // a[i] = a[j];
   // a[j] = t;
   // ++i;
   // --j;
   // }
   // }
   //
   // qsort(a, l, j + 1, rand);
   // qsort(a, i, r, rand);
   // }

   private BufferedReader br;
   private StringTokenizer tokenizer;
   private PrintWriter pw;
   private final boolean isFileIO = false;
}


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

public class Main{

    BufferedReader in;
    StringTokenizer str = null;
    PrintWriter out;

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

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

    int n;
    int []p;
    Map<Integer, Integer> map, cmap;
    Stack<Integer> stack;

    public void run() throws Exception{
    	in = new BufferedReader(new InputStreamReader(System.in));
    	out = new PrintWriter(System.out);

        n = nextInt();
        if (n % 2 == 1) {
            out.println("NO");
            out.close();
            return;
        }

        int p[] = new int[n];

        for(int i=0;i<n;i++){
            int x = nextInt();
            p[i] = x;
        }

        int m = nextInt();
        if (m > n/2) {
            out.println("NO");
            out.close();
            return;
        }

        for(int i=0;i<m;i++){
            int x = nextInt()-1;
            p[x]*=-1;
        }

        stack = new Stack<Integer>();
        for(int i=n-1;i>=0;i--){
            if (p[i] < 0) {
                stack.push(-1 * p[i]);
            }else{
                if (stack.size() > 0 && stack.peek() == p[i]){
                    stack.pop();
                }else{
                    stack.push(p[i]);
                    p[i]*=-1;
                }
            }
        }

        if (stack.size() > 0) {
            out.println("NO");
        }else{
            out.println("YES");
            for(int i=0;i<n;i++){
                out.print(p[i] + " ");
            }
            out.println();
        }
        out.close();
    }

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


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

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

class TaskE {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int counter = in.nextInt();
        int[] bracket = new int[counter];
        int[] stack = new int[counter];
        int size = 0;
        for (int i = 0; i < counter; ++i)
            bracket[i] = in.nextInt();
        counter = in.nextInt();
        for (int i = 0; i < counter; ++i) {
            int index = in.nextInt() - 1;
            bracket[index] = -bracket[index];
        }
        for (int i = bracket.length - 1; i >= 0; --i) {
            if (bracket[i] < 0)
                stack[size++] = bracket[i];
            else if (size > 0 && stack[size - 1] + bracket[i] == 0)
                size--;
            else {
                bracket[i] = -bracket[i];
                stack[size++] = bracket[i];
            }
        }
        if (size > 0)
            out.println("NO");
        else {
            out.println("YES");
            for (int i : bracket) {
                out.print(i);
                out.print(" ");
            }
        }
    }
}

class InputReader {

    private static BufferedReader bufferedReader;
    private static StringTokenizer stringTokenizer;

    public InputReader(InputStream inputStream) {
        bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        stringTokenizer = null;
    }

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

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

    }


import java.io.BufferedReader;
import java.io.StreamTokenizer;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.Reader;
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;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        if (n % 2 != 0) {
            out.print("NO");
            return;
        }
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = in.nextInt();
        }
        int t = in.nextInt();
        for (int i = 0; i < t; i++) {
            int k = in.nextInt();
            p[k - 1] *= -1;
        }

        int[] s = new int[n];
        int h = -1;

        for (int i = n - 1; i >= 0; i--) {
            if (p[i] < 0 || h < 0 || s[h] != p[i]) {
                if (p[i] > 0)
                    p[i] *= -1;
                h++;
                s[h] = -p[i];
            } else {
                h--;
            }
        }

        if (h >= 0) {
            out.print("NO");
            return;
        }

        out.println("YES");
        for (int i = 0; i < n; i++) {
            out.print(p[i]);
            out.print(' ');
        }
    }
}

class InputReader {
    private StreamTokenizer tokenizer;

    public InputReader(InputStream stream) {
        Reader r = new BufferedReader(new InputStreamReader(stream));
        tokenizer = new StreamTokenizer(r);
        tokenizer.eolIsSignificant(false);
        tokenizer.wordChars(34, 255);
    }

    public int nextInt() {
        try {
            int i = tokenizer.nextToken();
            if (i == StreamTokenizer.TT_NUMBER)
                return (int) tokenizer.nval;
            else
                throw new InputMismatchException("type = " + i);
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Stack;
import java.util.StringTokenizer;

public class E {
    public static void main(String[] args) throws Exception {
        int n = nextInt();
        int[] ar = new int[n];
        for (int i = 0; i < n; i++) {
            ar[i] = nextInt();
        }
        Stack<Integer> stack = new Stack<Integer>();
        int q = nextInt();
        int[] openBarcket = new int[n];
        for (int i = 0; i < q; i++) {
            openBarcket[nextInt() - 1] = 1;
        }
        for (int i = n - 1, j = 0; j < n; j++, i--) {
            if (stack.isEmpty() || stack.peek() != ar[i]) {
                stack.push(ar[i]);
            } else {
                if (openBarcket[i] == 1) {
                    stack.push(ar[i]);
                } else {
                    ar[i] *= -1;
                    stack.pop();
                }
            }
        }
        if (stack.isEmpty()) {
            PrintWriter out = new PrintWriter(System.out);
            out.println("YES");
            for (int i = 0; i < n; i++) {
                out.print((-ar[i]) + " ");
            }
            out.println();
            out.flush();
        } else {
            System.out.println("NO");
        }
    }

    static BufferedReader br = new BufferedReader(new InputStreamReader(
            System.in));
    static StringTokenizer tokenizer = new StringTokenizer("");

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

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

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

    static String next() throws Exception {
        while (true) {
            if (tokenizer.hasMoreTokens()) {
                return tokenizer.nextToken();
            }
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            tokenizer = new StringTokenizer(s);
        }
    }
}


import java.io.*;
import java.util.*;
public class z3 {
	public static void main(String[] args) throws IOException {
		StreamTokenizer in;
		PrintWriter out;
		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		out = new PrintWriter(new OutputStreamWriter(System.out));

		 in.nextToken();
		 int n=(int) in.nval;
	int[] a = new int[n];
	for (int i=0;i<n;i++) {in.nextToken(); a[i]=(int) in.nval;}
	in.nextToken();
	int t=(int) in.nval;
	int temp;
	for (int i=0;i<t;i++) {in.nextToken(); temp=(int) in.nval;a[temp-1]=-Math.abs(a[temp-1]);}
	if ((n%2)!=0) {out.println("NO");out.flush();}
	else
	  {
		int kol=0;int[] st=new int[n+1];
		  for (int i=n-1;i>=0;i--)
		  {
			  if (kol==0) {kol=1;st[kol]=Math.abs(a[i]);a[i]=-st[kol];} else
			  {
				  if (st[kol]==a[i]) kol-=1; else
				  {kol+=1;st[kol]=Math.abs(a[i]);a[i]=-st[kol];}
			  }
		  }
		  if (kol!=0) {out.println("NO");out.flush();} else
		  {
			  out.println("YES");
			  for (int i=0;i<n;i++) {out.print(a[i]);out.print(' ');}
			  out.flush();
		  }
	}
}
}


import java.io.*;
import java.util.*;
public class z3 {
	private static BufferedReader in;
	private static StringTokenizer tok;
	private static String readToken() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	private static int readInt() throws IOException {
		return Integer.parseInt(readToken());
	}

	public static void main(String[] args) throws IOException {
		PrintWriter out;
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new OutputStreamWriter(System.out));
		int n=readInt();
	int[] a = new int[n];
	for (int i=0;i<n;i++) a[i]=readInt();
	int t=readInt();
	int temp;
	for (int i=0;i<t;i++) {temp=readInt();a[temp-1]=-Math.abs(a[temp-1]);}
	if ((n%2)!=0) {out.println("NO");out.flush();}
	else
	  {
		int kol=0;int[] st=new int[n+1];
		  for (int i=n-1;i>=0;i--)
		  {
			  if (kol==0) {kol=1;st[kol]=Math.abs(a[i]);a[i]=-st[kol];} else
			  {
				  if (st[kol]==a[i]) kol-=1; else
				  {kol+=1;st[kol]=Math.abs(a[i]);a[i]=-st[kol];}
			  }
		  }
		  if (kol!=0) {out.println("NO");out.flush();} else
		  {
			  out.println("YES");
			  for (int i=0;i<n;i++) {out.print(a[i]);out.print(' ');}
			  out.flush();
		  }
	}
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;

public class Abood2D {

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

		int n = sc.nextInt();

		int[] P = new int[n];

		for (int i = 0; i < n; i++)
			P[i] = sc.nextInt();

		boolean[] Q = new boolean[n];
		boolean[] Ans = new boolean[n];
		boolean[] V = new boolean[n];

		int q = sc.nextInt();

		for (int i = 0; i < q; i++) {
			int x = sc.nextInt() - 1;
			Ans[x] = Q[x] = true;
		}

		int[] next = new int[n + 1];

		for (int i = 0; i <= n; i++)
			next[i] = i;

		for (int i = 0; i < n; i++) {
			if(Q[i]) {
				V[i] = true;
				Stack<Integer> s = new Stack<>();
				boolean f = false;
				for (int j = (i > 0 ? next[i - 1] : -1); j >= 0; j = (j > 0 ? next[j - 1] : -1)) {
					V[j] = true;
					if(P[j] == P[i] && s.isEmpty()) {
						f = true;
						next[i] = j > 0 ? next[j - 1] : -1;
						break;
					} else {
						if(!s.isEmpty() && P[s.peek()] == P[j])
							Ans[s.pop()] = true;
						else
							s.push(j);
					}
				}

				if(!f) {
					System.out.println("NO");
					return;
				}
			}
		}

		Stack<Integer> s = new Stack<>();

		for (int i = next[n - 1]; i >= 0; i--) {
			if(V[i])
				continue;
			if(!s.isEmpty() && P[s.peek()] == P[i])
				Ans[s.pop()] = true;
			else
				s.push(i);
		}

		if(s.isEmpty()) {
			out.println("YES");
			for (int i = 0; i < n; i++)
				out.print((Ans[i] ? -P[i] : P[i]) + " ");
			out.println();
		}else
			out.print("NO");

		out.flush();

	}

	static class Scanner

	{
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

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

	}

}


import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
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;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        if (n % 2 != 0) {
            out.print("NO");
            return;
        }
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = in.nextInt();
        }
        int t = in.nextInt();
        for (int i = 0; i < t; i++) {
            int k = in.nextInt();
            p[k - 1] *= -1;
        }

        int[] s = new int[n];
        int h = -1;

        for (int i = n - 1; i >= 0; i--) {
            if (p[i] < 0 || h < 0 || s[h] != p[i]) {
                if (p[i] > 0)
                    p[i] *= -1;
                h++;
                s[h] = -p[i];
            } else {
                h--;
            }
        }

        if (h >= 0) {
            out.print("NO");
            return;
        }

        out.println("YES");
        for (int i = 0; i < n; i++) {
            out.print(p[i]);
            out.print(' ');
        }

    }
}

class InputReader {
    private BufferedReader reader;
    private String[] line;
    private int index;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
    }

    public String next() {
        while (line == null) {
            try {
                line = reader.readLine().split("\\s");
                if (line.length == 0)
                    line = null;
                index = 0;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        String res = line[index];
        index++;
        if (index == line.length)
            line = null;
        return res;
    }

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


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

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

		Task solver = new Task();
		solver.solve(in, out);

		out.close();
	}
}

class InputReader {
	BufferedReader buff;
	StringTokenizer tokenizer;

	InputReader(InputStream stream) {
		buff = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}

	String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			try {
				tokenizer = new StringTokenizer(buff.readLine());
			}
			catch (IOException e) {
				throw new RuntimeException(e);
			}
		return tokenizer.nextToken();
	}
	int nextInt() { return Integer.parseInt(next()); }
	long nextLong() { return Long.parseLong(next()); }
}

class Task {
	final static int MAXL = 19;
	final static int[] prim = {2, 3, 5, 7};
	final static int[] pow = {12, 4, 2, 1};
	final static int MAXN = 48;
	final static int MAXM = 252;
	final static int LCM = 2520;
	long[][][] dp;

	int encode(int[] x) {
		int ret = 0;
		for (int i = 0; i < pow.length; ++i)
			ret += x[i] * pow[i];
		return ret;
	}

	int[] decode(int x) {
		int[] ret = new int[4];
		for (int i = 0; i < pow.length; ++i) {
			ret[i] = x / pow[i];
			x %= pow[i];
		}
		return ret;
	}

	int merge(int mask, int x) {
		if (x == 0)
			return mask;
		int[] ret = decode(mask);
		for (int i = 0; i < prim.length; ++i) {
			int cnt = 0;
			while (x % prim[i] == 0) {
				x /= prim[i];
				++cnt;
			}
			ret[i] = Math.max(ret[i], cnt);
		}
		return encode(ret);
	}

	long divTest(int x, int mask) {
		int[] ret = decode(mask);
		for (int i = 0; i < prim.length; ++i) {
			int now = 1;
			for (int j = 0; j < ret[i]; ++j)
				now *= prim[i];
			if (x % now != 0)
				return 0L;
		}
		return 1L;
	}

	long go(long l, long r) {
		int[] a = new int[MAXL], b = new int[MAXL];
		int pos = -1;
		for (int i = 0; i < MAXL; ++i) {
			a[i] = (int)(l % 10);
			b[i] = (int)(r % 10);
			if (a[i] != b[i])
				pos = i;
			l /= 10; r /= 10;
		}

		long ret = 0;
		int[] rem = new int[MAXL], mask = new int[MAXL];
		for (int i = MAXL - 2; i >= 0; --i) {
			rem[i] = (rem[i + 1] + a[i + 1]) * 10 % LCM;
			mask[i] = merge(mask[i + 1], a[i + 1]);
		}

		for (int i = 0; i <= pos; ++i)
			for (int j = a[i] + 1; j < (i == pos ? b[i] : 10); ++j)
				if (i == 0)
					ret += divTest(rem[i] + j, merge(mask[i], j));
				else
					ret += dp[i][merge(mask[i], j)][(rem[i] + j) * 10 % LCM / 10];

		rem = new int[MAXL]; mask = new int[MAXL];
		for (int i = MAXL - 2; i >= 0; --i) {
			rem[i] = (rem[i + 1] + b[i + 1]) * 10 % LCM;
			mask[i] = merge(mask[i + 1], b[i + 1]);
		}
		for (int i = pos - 1; i >= 0; --i)
			for (int j = 0; j < b[i]; ++j)
				if (i == 0)
					ret += divTest(rem[i] + j, merge(mask[i], j));
				else
					ret += dp[i][merge(mask[i], j)][(rem[i] + j) * 10 % LCM / 10];

		return ret;
	}

	void solve(InputReader in, PrintWriter out) {
		dp = new long[MAXL][MAXN][MAXM];
		for (int i = 0; i < MAXN; ++i)
			for (int j = 0; j < MAXM; ++j)
				for (int c = 0; c < 10; ++c)
					dp[1][i][j] += divTest(j * 10 + c, merge(i, c));

		//out.println(Arrays.toString(decode(4)));
		//out.println(dp[1][4][3]);
		for (int i = 2; i < MAXL; ++i)
			for (int j = 0; j < MAXN; ++j)
				for (int k = 0; k < MAXM; ++k)
					for (int c = 0; c < 10; ++c)
						dp[i][j][k] += dp[i - 1][merge(j, c)][(k * 10 + c) * 10 % LCM / 10];

		for (int q = in.nextInt(); q-- > 0; ) {
			long l = in.nextLong(), r = in.nextLong();
			out.println(go(l - 1, r + 1));
		}
	}
}


// practice with rainboy
import java.io.*;
import java.util.*;

public class CF553B extends PrintWriter {
	CF553B() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF553B o = new CF553B(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[] ff = new long[n + 1];
		ff[0] = ff[1] = 1;
		for (int i = 2; i <= n; i++)
			ff[i] = ff[i - 2] + ff[i - 1];
		int a = 0;
		while (n > 0)
			if (k <= ff[n - 1]) {
				print((a + 1) + " ");
				a++;
				n--;
			} else {
				k -= ff[n - 1];
				print((a + 2) + " " + (a + 1) + " ");
				a += 2;
				n -= 2;
			}
		println();
	}
}


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

public class A {

    long mod = (long) 1e9 + 7;

    class Num {
        final long a, b;

        public Num(long a, long b) {
            this.a = a % mod;
            this.b = b % mod;
        }

        public Num add(Num other) {
            return new Num(a + other.a, b + other.b);
        }

        public Num multiply(Num other) {
            return new Num(a * other.a + 5 * b * other.b, a * other.b + b * other.a);
        }
    }

    int k;

    long[][] coeffs;

    void prepare() {
        coeffs = new long[k + 1][k + 1];
        long[][] tmpCoeffs = new long[k + 1][k + 1];
        long factK = 1;
        coeffs[0][0] = 1;

        for (int free = 0; free < k; free++) {
            factK = factK * (free + 1) % mod;

            for (int i = 0; i <= k; i++) {
                for (int j = 0; j <= k; j++) {
                    if (coeffs[i][j] != 0) {
                        tmpCoeffs[i + 1][j] += coeffs[i][j];
                        if (tmpCoeffs[i + 1][j] >= mod) {
                            tmpCoeffs[i + 1][j] -= mod;
                        }

                        tmpCoeffs[i][j + 1] += coeffs[i][j];
                        if (tmpCoeffs[i][j + 1] >= mod) {
                            tmpCoeffs[i][j + 1] -= mod;
                        }

                        long add = coeffs[i][j] * (mod - free) % mod;
                        tmpCoeffs[i][j] += add;
                        if (tmpCoeffs[i][j] >= mod) {
                            tmpCoeffs[i][j] -= mod;
                        }
                    }
                }
            }

            for (int i = 0; i <= k; i++) {
                for (int j = 0; j <= k; j++) {
                    coeffs[i][j] = tmpCoeffs[i][j];
                    tmpCoeffs[i][j] = 0;
                }
            }
        }

        factK = inv(factK);
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                coeffs[i][j] = coeffs[i][j] * factK % mod;
            }
        }
//        System.err.println(Arrays.deepToString(coeffs));

        pow1 = new Num[k + 1];
        powA = new Num[k + 1];
        pow2 = new Num[k + 1];
        powB = new Num[k + 1];

        pow1[0] = pow2[0] = powA[0] = powB[0] = new Num(1, 0);
        for (int i = 1; i <= k; i++) {
            pow1[i] = pow1[i - 1].multiply(PHI1);
            pow2[i] = pow2[i - 1].multiply(PHI2);
            powA[i] = powA[i - 1].multiply(A);
            powB[i] = powB[i - 1].multiply(B);
        }
    }

    long inv(long x) {
        return pow(x, mod - 2);
    }

    long pow(long a, long b) {
        long res = 1;
        while (b != 0) {
            if ((b & 1) == 1) {
                res = res * a % mod;
            }
            a = a * a % mod;
            b >>>= 1;
        }
        return res;
    }

    final Num PHI1 = new Num(inv(2), inv(2));
    final Num PHI2 = new Num(inv(2), mod - inv(2));
    final Num A = new Num(0, inv(5));
    final Num B = new Num(0, mod - inv(5));

    final Num ONE = new Num(1, 0);

    Num[] pow1, pow2, powA, powB;

    long get(long n) {
        Num result = new Num(0, 0);

        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                long coef = coeffs[i][j];
                if (coef == 0) {
                    continue;
                }

                Num cur = new Num(coef, 0).multiply(powA[i]).multiply(powB[j]);

                Num x = pow1[i].multiply(pow2[j]);
                x = geomSum(x, n + 1);

                result = result.add(cur.multiply(x));
            }
        }
        return result.a;
    }

    Num geomSum(Num x, long n) {
        if (n == 0) {
            return new Num(0, 0);
        }
        if (n % 2 == 0) {
            Num x2 = x.multiply(x);
            Num result = geomSum(x2, n / 2);
            return (ONE.add(x)).multiply(result);
        } else {
            return ONE.add(x.multiply(geomSum(x, n - 1)));
        }
    }

    public void solve() {
        k = in.nextInt();
        prepare();
        long l = in.nextLong(), r = in.nextLong();
//        for (int i = 0; i < 20; i++) {
//            Num fib = A.multiply(pow1[i]).add(B.multiply(pow2[i]));
//            System.err.println(fib.a + " " + fib.b);
//            System.err.println(get(i + 1) - get(i));
//        }
        out.println((get(r + 2) - get(l + 1) + mod) % mod);
    }

    public void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    FastScanner in;
    PrintWriter out;

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
            }
        }

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

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

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

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

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

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


import java.io.*;
import java.nio.charset.Charset;
import java.util.*;

public class CFCR493B {
    public static void main(String[] args) throws Exception {
        boolean local = System.getProperty("ONLINE_JUDGE") == null;
        boolean async = false;

        Charset charset = Charset.forName("ascii");

        FastIO io = local ? new FastIO(new FileInputStream("E:\\DATABASE\\TESTCASE\\CFCR493B.in"), new FileOutputStream("E:\\DATABASE\\TESTCASE\\CFCR493B.out"), charset) : new FastIO(System.in, System.out, charset);
        Task task = new Task(io);

        if (async) {
            Thread t = new Thread(null, task, "dalt", 1 << 27);
            t.setPriority(Thread.MAX_PRIORITY);
            t.start();
            t.join();
        } else {
            task.run();
        }

        io.flush();
    }

    public static class Task implements Runnable {
        final FastIO io;

        public Task(FastIO io) {
            this.io = io;
        }

        @Override
        public void run() {
            solve();
        }

        public void solve() {
            int n = io.readInt();

            long total = 0;

            for (int i = 0; i < 9; i++) {
                for (int j = 0; j < 9; j++) {
                    if (i >= 5 && j >= 1 || i + j > n) {
                        continue;
                    }
                    total += (n - i - j + 1);
                }
            }

            io.cache.append(total);
        }

    }

    public static class FastIO {
        private final InputStream is;
        private final OutputStream os;
        private final Charset charset;
        private StringBuilder defaultStringBuf = new StringBuilder(1 << 8);
        public final StringBuilder cache = new StringBuilder();

        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastIO(InputStream is, OutputStream os, Charset charset) {
            this.is = is;
            this.os = os;
            this.charset = charset;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                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;
        }

        public long readLong() {
            int sign = 1;

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

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

        public double readDouble() {
            long num = readLong();
            if (next != '.') {
                return num;
            }

            next = read();
            long divisor = 1;
            long later = 0;
            while (next >= '0' && next <= '9') {
                divisor = divisor * 10;
                later = later * 10 + next - '0';
                next = read();
            }

            if (num >= 0) {
                return num + (later / (double) divisor);
            } else {
                return num - (later / (double) divisor);
            }
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

        public int readString(char[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (char) next;
                next = read();
            }

            return offset - originalOffset;
        }

        public int readString(byte[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (byte) next;
                next = read();
            }

            return offset - originalOffset;
        }

        public void flush() {
            try {
                os.write(cache.toString().getBytes(charset));
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public boolean hasMore() {
            skipBlank();
            return next != -1;
        }
    }

    public static class Memory {
        public static <T> void swap(T[] data, int i, int j) {
            T tmp = data[i];
            data[i] = data[j];
            data[j] = tmp;
        }

        public static <T> int min(T[] data, int from, int to, Comparator<T> cmp) {
            int m = from;
            for (int i = from + 1; i < to; i++) {
                if (cmp.compare(data[m], data[i]) > 0) {
                    m = i;
                }
            }
            return m;
        }

        public static <T> void move(T[] data, int from, int to, int step) {
            int len = to - from;
            step = len - (step % len + len) % len;
            Object[] buf = new Object[len];
            for (int i = 0; i < len; i++) {
                buf[i] = data[(i + step) % len + from];
            }
            System.arraycopy(buf, 0, data, from, len);
        }
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map.Entry;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Techno19_2F {

	static int MODE = -1;

	static final Comparator<int[]> COMP_ARR = new Comparator<int[]>() {
		public int compare(int[] a1, int[] a2) {
			if (MODE != -1 && (a1.length == 32 || a2.length == 32)) {
				if (a1.length == 32) {
					if (MODE < a2.length) {
						return -1;
					}
					if (MODE > a2.length) {
						return 1;
					}
				} else {
					if (a1.length < MODE) {
						return -1;
					}
					if (a1.length > MODE) {
						return 1;
					}
				}

				for (int i = 0; i < MODE; i++) {
					if (a1[i] < a2[i]) {
						return -1;
					}
					if (a1[i] > a2[i]) {
						return 1;
					}
				}
				return 0;
			} else {
				if (a1.length < a2.length) {
					return -1;
				}
				if (a1.length > a2.length) {
					return 1;
				}

				for (int i = 0; i < a2.length; i++) {
					if (a1[i] < a2[i]) {
						return -1;
					}
					if (a1[i] > a2[i]) {
						return 1;
					}
				}
				return 0;
			}
		}
	};

	static TreeMap<int[], Integer> index = new TreeMap<>(COMP_ARR);
	static int[][] states;

	static ArrayList<int[]> start = new ArrayList<>();

	static int[] numD;

	static int[] pFact = new int[1_000_001];

	static TreeMap<int[], Integer> divCostInd = new TreeMap<>(COMP_ARR);

	public static void main(String[] args) throws IOException {
		cGen = new int[23];
		numD = new int[6000];
		states = new int[6000][];
		genAll(0, 23, 23, 1);

		aList = new ArrayList[6000];
		for (int i = 0; i < 6000; i++) {
			aList[i] = new ArrayList<>();
		}
		fAList();

		divCost = new int[400][301];
		for (int[] a : divCost) {
			Arrays.fill(a, Integer.MAX_VALUE / 2);
		}
		cost = new int[index.size()];

		Arrays.fill(pFact, 1);
		for (int i = 2; i <= 1_000_000; i++) {
			if (pFact[i] == 1) {
				for (int m = i; m <= 1_000_000; m += i) {
					pFact[m] = i;
				}
			}
		}

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

		int nT = Integer.parseInt(reader.readLine());

		while (nT-- > 0) {
			StringTokenizer inputData = new StringTokenizer(reader.readLine());
			int a = Integer.parseInt(inputData.nextToken());
			int b = Integer.parseInt(inputData.nextToken());

			int[] aA = toArray(a);
			int[] bA = toArray(b);

			Integer aRes = divCostInd.get(aA);
			if (aRes == null) {
				aRes = divCostInd.size();
				bfs(aA, divCostInd.size());
				divCostInd.put(aA, divCostInd.size());
			}
			Integer bRes = divCostInd.get(bA);
			if (bRes == null) {
				bRes = divCostInd.size();
				bfs(bA, divCostInd.size());
				divCostInd.put(bA, divCostInd.size());
			}

			int minA = Integer.MAX_VALUE / 4;
			for (int nD = 1; nD <= 300; nD++) {
				minA = Math.min(minA, divCost[aRes][nD] + divCost[bRes][nD]);
			}
			printer.println(minA);
		}
		printer.close();
	}

	static int[] toArray(int a) {
		ArrayList<Integer> cnts = new ArrayList<Integer>();
		int last = -1;
		int cCnt = 0;

		while (a > 1) {
			int cPFact = pFact[a];
			if (cPFact == last) {
				cCnt++;
			} else {
				if (cCnt != 0) {
					cnts.add(cCnt);
				}
				last = cPFact;
				cCnt = 1;
			}
			a /= pFact[a];
		}
		if (cCnt != 0) {
			cnts.add(cCnt);
		}
		Collections.sort(cnts, Comparator.reverseOrder());
		int[] res = new int[cnts.size()];
		for (int i = 0; i < cnts.size(); i++) {
			res[i] = cnts.get(i);
		}
		return res;
	}

	static int[] cost;

	static int[][] divCost;

	static void bfs(int[] sState, int searchI) {
		int sInd = index.get(sState);
		ArrayDeque<Integer> queue = new ArrayDeque<>();

		queue.add(index.get(sState));

		Arrays.fill(cost, -1);
		cost[sInd] = 0;

		while (!queue.isEmpty()) {
			int cStInd = queue.remove();
			for (int nStInd : aList[cStInd]) {
				if (cost[nStInd] == -1) {
					cost[nStInd] = cost[cStInd] + 1;
					queue.add(nStInd);
				}
			}
		}

		for (Entry<int[], Integer> cE : index.entrySet()) {
			int cNumD = numD[cE.getValue()];
			if (cNumD <= 300) {
				divCost[searchI][cNumD] = Math.min(divCost[searchI][cNumD], cost[cE.getValue()]);
			}
		}
	}

	static ArrayList<Integer>[] aList;

	static void fAList() {
		int[] cState = new int[32];
		for (Entry<int[], Integer> cE : index.entrySet()) {
			int[] oState = cE.getKey();
			int cStInd = cE.getValue();

			int cLen = states[cStInd].length;
			for (int i = 0; i < cLen; i++) {
				cState[i] = oState[i];
			}
			MODE = cLen;

			for (int i = 0; i < cLen; i++) {
				if (i == 0 || cState[i - 1] > cState[i]) {
					cState[i]++;
					Integer nStInd = index.get(cState);
					cState[i]--;

					if (nStInd == null) {
						continue;
					}
					aList[cStInd].add(nStInd);
				}

				if (i == cLen - 1 && cState[i] == 1) {
					MODE--;
					Integer nStInd = index.get(cState);
					MODE++;
					if (nStInd == null) {
						continue;
					}
					aList[cStInd].add(nStInd);
				} else if (i == cLen - 1 || cState[i] > cState[i + 1]) {
					cState[i]--;
					Integer nStInd = index.get(cState);
					cState[i]++;
					if (nStInd == null) {
						continue;
					}
					aList[cStInd].add(nStInd);
				}
			}
			cState[cLen] = 1;

			MODE++;
			Integer nStInd = index.get(cState);
			MODE--;
			if (nStInd == null) {
				continue;
			}
			aList[cStInd].add(nStInd);
		}
	}

	static int[] cGen;

	static void genAll(int i, int max, int rem, int cProd) {
		numD[index.size()] = cProd;

		int[] cKey = Arrays.copyOf(cGen, i);
		states[index.size()] = cKey;
		index.put(cKey, index.size());

		if (rem > 0) {
			for (int nV = Math.min(max, rem); nV >= 1; nV--) {
				cGen[i] = nV;
				genAll(i + 1, nV, rem - nV, cProd * (nV + 1));
			}
		}
	}
}


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

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

class TaskE {
    private static final int MOD = 1000000007;
    private static final long[][] choose;
    static {
        choose = new long[55][55];
        for (int i = 0; i <= 51; ++i) {
            choose[i][0] = choose[i][i] = 1;
            for (int j = 1; j < i; ++j) {
                choose[i][j] = (choose[i - 1][j] + choose[i - 1][j - 1]) % MOD;
            }
        }
    }
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt(), k = in.nextInt();

        if (k > n) {
            out.println(0);
            return;
        }

        int[][][] dp = new int[n + 1][2][n + 1];
        dp[1][0][0] = 1;
        dp[0][1][0] = 1;
        for (int i = 2; i <= n; ++i) {
            for (int j = 0; j < 2; ++j) {
                for (int match = 0; match <= i; ++match) {
                    for (int left = 0; left < 2; ++left) {
                        for (int right = 0; right < 2; ++right) {
                            if ((left == 0 || right == 0) && j == 0) continue;
                            if (left == 1 && right == 1 && j == 1) continue;
                            int rem = match - j;
                            if (rem < 0) continue;
                            for (int leftSize = 0; leftSize < i; ++leftSize) {
                                for (int leftMatch = 0; leftMatch <= leftSize && leftMatch <= rem; ++leftMatch) {
                                    int rightSize = i - 1 - leftSize;
                                    int rightMatch = rem - leftMatch;
                                    if (rightMatch > rightSize) continue;
                                    if (leftSize < rightSize || leftSize == rightSize && leftMatch < rightMatch) {
                                        dp[i][j][match] = (int) ((dp[i][j][match] + dp[leftSize][left][leftMatch]
                                                * (long) dp[rightSize][right][rightMatch] % MOD * (i == n ? 1 : i) % MOD * choose[i - 1][leftSize] % MOD) % MOD);
                                    } else if (leftSize == rightSize && leftMatch == rightMatch) {
                                        dp[i][j][match] = (int) ((dp[i][j][match] + dp[leftSize][left][leftMatch]
                                                * (long) (dp[rightSize][right][rightMatch] - 1) % MOD * NumberUtils.powMod(2, MOD - 2, MOD) % MOD * (i == n ? 1 : i) % MOD * choose[i - 1][leftSize] % MOD) % MOD);
                                        dp[i][j][match] = (int) ((dp[i][j][match] + dp[leftSize][left][leftMatch] * (long) (i == n ? 1 : i) % MOD * choose[i - 1][leftSize] % MOD * NumberUtils.powMod(2, MOD - 2, MOD) % MOD) % MOD);
                                    }
//                                    if (i == 3 && j == 1 && match == 1) {
//                                        out.println("left = " + left + " right = " + right + " ls = " + leftSize + " lm = " + leftMatch + " rs = " + rightSize + " rm = " + rightMatch + " i = " + i + " j = " + j + " match = " + match + " res = " + dp[i][j][match]);
//                                    }
                                 }
                            }
                        }
                    }
//                    out.println("i = " + i + " j = " + j + " match = " + match + " res = " + dp[i][j][match]);
                }
            }
        }

        out.println((((dp[n][0][k] + dp[n][1][k]) % MOD) + MOD) % MOD);
    }
}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

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

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

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

    }

class NumberUtils {

    public static long powMod(long x, long y, long mod) {
        long res = 1;
        for (; y != 0; y >>= 1L) {
            if (y % 2 == 1) res = res * x % mod;
            x = x * x % mod;
        }
        return res;
    }

    }


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

public class Main {

	BufferedReader in;
	StringTokenizer str = null;
	PrintWriter out;

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

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

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

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

	final long MOD = (long)(1e9) + 7;
	long []f;

	final int MAXN = 200010;

	public void run() throws Exception{
		in =  new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		int n = nextInt(), m = nextInt(), g = nextInt();
		if (n == 0) {
			if (m > 1) {
				if (g == 0) {
					out.println(1);
				}else {
					out.println(0);
				}
			}else {
				if (g == 1) {
					out.println(1);
				}else {
					out.println(0);
				}
			}
			out.close();
			return;
		}
		if (m == 0) {
			if (n % 2 == 0) {
				out.println(g);
			}else {
				out.println(g ^ 1);
			}
			out.close();
			return;
		}
		f = new long[MAXN];
		f[0] = 1;
		for(int i = 1; i < MAXN; ++i) f[i] = (f[i-1] * i) % MOD;
		long ret = 0;
		for(int i = 0; i <= n; ++i) {
			if (i % 2 == 0) {
				if (m - 1 > 0 || n - i > 0) {
					if (g == 0) ret += C(m - 1, n - i + m - 1);
				}else {
					if (g == 1) ret += 1;
				}
			}else {
				if (m - 1 > 0 || n - i > 0) {
					if (g == 1) ret += C(m - 1, n - i + m - 1);
				}else {
					if (g == 0) ret += 1;
				}
			}
			if (ret >= MOD) ret -= MOD;
		}
		out.println(ret);
		out.close();
	}

	private long C(int m, int n){
		long ret = f[n];
		ret *= inv((f[m] * f[n - m]) % MOD, MOD);
		return ret % MOD;
	}

	private long inv(long a, long b) {
		return pow(a, b - 2);
	}

	private long pow(long x, long p) {
		long ret = 1;
		while(p > 0) {
			if (p % 2 == 1) ret = (ret * x) % MOD;
			x = (x * x) % MOD;
			p >>= 1;
		}
		return ret;
	}

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


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

public class C {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
if (n == 1) {
out.println(1);
return;}
		long allPairs = (long) n * m * (n * m - 1);
		long goodPairs = (long) n * m * (m - 1);
		double p2 = 1.0 * goodPairs / allPairs;
		out.println(1.0 / n + (n - 1.0) / n * p2);
	}

	C() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

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

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

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

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

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


import java.io.*;import java.util.*;public class codeforces452C{public static void main(String[] args) throws IOException{StringTokenizer st=new StringTokenizer(new BufferedReader(new InputStreamReader(System.in)).readLine());double N=Double.parseDouble(st.nextToken()),M=Double.parseDouble(st.nextToken());System.out.printf("%.12f\n",(N==1&&M==1) ? 1.0 : ((1/N)+((M-1)*(N-1))/(N*(N*M-1))));}}


import java.io.*;
import java.lang.*;
import static java.lang.Math.*;
import java.lang.reflect.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.security.CodeSource;
import java.security.KeyStore;
import java.util.*;
import static java.util.Arrays.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;

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

    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();
            }
        }
        solve();
        //if( oj )
        err.println("Time: " + (System.currentTimeMillis() - timeBegin) / 1e3);
        out.flush();
    }

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

    private boolean eq(String a, String b) {
        for( int i = 0; i < a.length(); ++i ){
            if( a.charAt(i) == '.' ) continue;
            if( b.charAt(i) == '.' ) continue;
            if( a.charAt(i) != b.charAt(i) )
                return false;
        }
        return true;
    }

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

    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>

    double[] logFact = new double[(int)5e6];
    {
        logFact[0] = log(1);
        for (int i = 1; i < logFact.length; i++) {
            logFact[i] = logFact[i-1] + log(i);
        }
        err.println("f:" + exp(logFact[7]));
    }

    double logC( int m, int n ){
        return logFact[n] - logFact[m] - logFact[n-m];
    }

    void solve() {
        int n = sc.nextInt();
        int m = sc.nextInt();;
        double ans = 0;
        for( int cnt = 1; cnt <= min(n,m); ++cnt ){
            double cur = logC(cnt,m) + logC(n-cnt,n*m-m) - logC(n,n*m);
            if( -50 <= cur  ){
                cur = exp(cur);
                cur = cur * cnt * cnt / n;
                ans += cur;
            }
        }
        out.printf( "%.10f\n", ans);
    }

}


import java.io.*;
import java.lang.*;
import static java.lang.Math.*;
import java.lang.reflect.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.security.CodeSource;
import java.security.KeyStore;
import java.util.*;
import static java.util.Arrays.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;

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

    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();
            }
        }
        solve();
        //if( oj )
        err.println("Time: " + (System.currentTimeMillis() - timeBegin) / 1e3);
        out.flush();
    }

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

    private boolean eq(String a, String b) {
        for( int i = 0; i < a.length(); ++i ){
            if( a.charAt(i) == '.' ) continue;
            if( b.charAt(i) == '.' ) continue;
            if( a.charAt(i) != b.charAt(i) )
                return false;
        }
        return true;
    }

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

    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>

    static double[] logFact = new double[(int)1e6+1];
    static {
        logFact[0] = log(1);
        for (int i = 1; i < logFact.length; i++) {
            logFact[i] = logFact[i-1] + log(i);
        }
        System.err.println("f:" + exp(logFact[7]));
    }

    double logC( int m, int n ){
        return logFact[n] - logFact[m] - logFact[n-m];
    }

    void solve() {
        int n = sc.nextInt();
        int m = sc.nextInt();;
        double ans = 0;
        for( int cnt = 1; cnt <= min(n,m); ++cnt ){
            double cur = logC(cnt,m) + logC(n-cnt,n*m-m) - logC(n,n*m);
//            if( -50 <= cur  ){
                cur = exp(cur);
                cur = cur * cnt * cnt / n;
                ans += cur;

//            }
        }
        out.printf( "%.10f\n", ans);
    }

}


import java.io.*;
import java.lang.*;
import static java.lang.Math.*;
import java.lang.reflect.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.security.CodeSource;
import java.security.KeyStore;
import java.util.*;
import static java.util.Arrays.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;

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

    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();
            }
        }
        solve();
        //if( oj )
        err.println("Time: " + (System.currentTimeMillis() - timeBegin) / 1e3);
        out.flush();
    }

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

    private boolean eq(String a, String b) {
        for( int i = 0; i < a.length(); ++i ){
            if( a.charAt(i) == '.' ) continue;
            if( b.charAt(i) == '.' ) continue;
            if( a.charAt(i) != b.charAt(i) )
                return false;
        }
        return true;
    }

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

    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>

    double[] logFact = new double[(int)1e6+1];
    {
        logFact[0] = log(1);
        for (int i = 1; i < logFact.length; i++) {
            logFact[i] = logFact[i-1] + log(i);
        }
        err.println("f:" + exp(logFact[7]));
    }

    double logC( int m, int n ){
        return logFact[n] - logFact[m] - logFact[n-m];
    }

    void solve() {
        int n = sc.nextInt();
        int m = sc.nextInt();;
        double ans = 0;
        for( int cnt = 1; cnt <= min(n,m); ++cnt ){
            double cur = logC(cnt,m) + logC(n-cnt,n*m-m) - logC(n,n*m);
//            if( -50 <= cur  ){
                cur = exp(cur);
                cur = cur * cnt * cnt / n;
                ans += cur;
//            }
        }
        out.printf( "%.10f\n", ans);
    }

}


import java.util.Scanner;

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

/**
 *
 * @author ASUS
 */
public class NewClass {

public static void main(String[] args) {

    Scanner sc=new Scanner(System.in);
          double m,n;

          n=sc.nextDouble();
          m=sc.nextDouble();

    if ( n == 1 ) {
        System.out. printf ("%.10f", 1. );

    }
    else
    if ( m == 1 ) {
         System.out. printf ("%.10f", 1. / n );

    }
    else
     System.out. printf ("%.10f", 1. / n + ( ( ( n - 1 ) /  n  ) * (  (m - 1 ) / ( n * m - 1 ) ) ) );
     //System.out. printf("%.10lf",1./n+(  ( ( n - 1 ) /  ( n ) )  ));

    System.out.println();
}

}


import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class ProblemC {
	static final long MOD = 1000000007;

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

		int n = in.nextInt();
		long[] a = new long[n];
		for (int i = 0 ; i < n ; i++) {
			a[i] = in.nextLong();
		}
		Arrays.sort(a);

		long best = Long.MAX_VALUE;

		boolean[] isp = new boolean[1000010];
		Arrays.fill(isp, true);
		isp[1] = false;
		for (int i = 2 ; i < 1000010 ; i++) {
			if (isp[i]) {
				for (long ii = 1L * i * i ; ii < 1000010 ; ii += i) {
					isp[(int)ii] = false;
				}
			}
		}
		List<Integer> primes = new ArrayList<Integer>();
		for (int i = 1 ; i < 1000010 ; i++) {
			if (isp[i]) {
				primes.add(i);
			}
		}

		cnt = new long[n];
		for (int i = 0 ; i < n ; i++) {
			long nw = a[i];
			for (int p : primes) {
				while (nw % p == 0) {
					nw /= p;
					cnt[i]++;
				}
			}
			if (nw >= 2) {
				cnt[i]++;
			}
		}
		N = n;

		int[] parent = new int[n];
		Arrays.fill(parent, -1);
		out.println(doit(0, a, parent));
		out.flush();
	}

	static int N;
	static long[] cnt;

	public static long doit(int done, long[] a, int[] parent) {
		if (done == (1<<N)-1) {
			long best = 0;
			for (int i = 0 ; i < N ; i++) {
				long deg = cnt[i];
				boolean hasChild = false;
				for (int j = 0 ; j < N ; j++) {
					if (parent[j] == i) {
						deg -= cnt[j];
						hasChild = true;
					}
				}
				best += deg;
				if (hasChild || cnt[i] >= 2) {
					best++;
				}
			}
			int pcnt = 0;
			for (int j = 0 ; j < N ; j++) {
				if (parent[j] == -1) {
					pcnt++;
				}
			}
			best += (pcnt == 1) ? 0 : 1;
			//debug(pcnt,best);
			return best;
		}
		long best = Long.MAX_VALUE;
		for (int pl = N-1 ; pl >= 0 ; pl--) {
			if ((done & (1<<pl)) != 0) {
				continue;
			}
			for (int p = 0 ; p < N ; p++) {
				if ((done & (1<<p)) == 0) {
					continue;
				}
				if (a[p] % a[pl] == 0) {
					parent[pl] = p;
					long rev = a[p];
					a[p] /= a[pl];
					best = Math.min(best, doit(done | (1<<pl), a, parent));
					a[p] = rev;
					parent[pl] = -1;
				}
			}
			parent[pl] = -1;
			best = Math.min(best, doit(done | (1<<pl), a, parent));
			break;
		}
		return best;
	}

	public static void debug(Object... o) {
		System.err.println(Arrays.deepToString(o));
	}
}


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

public class Main implements Runnable {

    public void _main() throws Exception {
	int n = nextInt();
	int m = nextInt();
	int x1 = nextInt();
	int y1 = nextInt();
	int x2 = nextInt();
	int y2 = nextInt();
	int h = Math.abs(x1 - x2) + 1;
	int w = Math.abs(y1 - y2) + 1;
	if ((h >= 4 && w >= 5) || (h >= 5 && w >= 4) || h >= 6 || w >= 6) {
	    out.println("Second");
	} else {
	    out.println("First");
	}
    }

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer st;

    private String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String rl = in.readLine();
            if (rl == null) return null;
            st = new StringTokenizer(rl);
        }
        return st.nextToken();
    }

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

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

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

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            _main();

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

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

}


import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.Vector;
public class Main {
	static final long mod=1000000007;
	public static void main(String[] args) {
		long a[]=new long[20];
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long s=sc.nextLong();
		for(int i=0;i<n;i++)
				a[i]=sc.nextLong();
		int len=(1<<n);
		long ans=0;
		for(int i=0;i<len;i++){
			long x=s;
			int flag=1;
			for(int j=0;j<n;j++)
				if(((i>>j)&1)==1){
					flag*=-1;
					x-=a[j]+1;
				}
			if(x<0)
				continue;
			ans=(ans+flag*lucas(x+n-1,n-1))%mod;
			ans=(ans+mod)%mod;
		}
		System.out.println(ans);
	}
	static long lucas(long a,long b){
		if(b==0)
			return 1;
		return getc(a%mod,b%mod)*lucas(a/mod,b/mod)%mod;
	}
	static long getc(long a,long b){
		if(a<b)
			return 0;
		long ans=1;
		for(long i=a-b+1;i<=a;i++)
			ans=ans*i%mod;
		long t=1;
		for(long i=1;i<=b;i++)
			t=t*i%mod;
		return ans*qpow(t,mod-2)%mod;
	}
	static long qpow(long a,long b){
		long ans=1;
		while(b!=0){
			if((b&1)==1){
				ans=a*ans%mod;
			}
			a=a*a%mod;
			b>>=1;
		}
		return ans;
	}
}


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

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

class TaskE {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n=in.readInt(), MOD=1000000007;
        long s=in.readLong(), ret=0;
        long[] F= IOUtils.readLongArray(in, n), revFac=IntegerUtils.generateReverseFactorials(n, MOD);
        for (int mask=0; mask<1<<n; mask++) {
            long used=0;
            for (int i=0; i<n; i++) if ((mask&(1<<i))>0)  used+=F[i]+1;
            if (used>s) continue;
            long s2=s-used, x=revFac[n-1];
            for (int i=1; i<n; i++) x=(s2+n-i)%MOD*x%MOD;
            ret=(ret+(Integer.bitCount(mask)%2==0?1:-1)*x+MOD)%MOD;
        }
        out.printLine(ret);
    }
}

class InputReader {

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

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

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

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

    public long readLong() {
        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);
    }
}

class OutputWriter {
    private final PrintWriter writer;

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

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

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

}

class IOUtils {

    public static long[] readLongArray(InputReader in, int size) {
        long[] array = new long[size];
        for (int i = 0; i < size; i++)
            array[i] = in.readLong();
        return array;
    }

}

class IntegerUtils {

    public static long[] generateReverse(int upTo, long module) {
        long[] result = new long[upTo];
        if (upTo > 1)
            result[1] = 1;
        for (int i = 2; i < upTo; i++)
            result[i] = (module - module / i * result[((int) (module % i))] % module) % module;
        return result;
    }

    public static long[] generateReverseFactorials(int upTo, long module) {
        long[] result = generateReverse(upTo, module);
        if (upTo > 0)
            result[0] = 1;
        for (int i = 1; i < upTo; i++)
            result[i] = result[i] * result[i - 1] % module;
        return result;
    }

}


import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class DevuAndFlowers {

	static long mod = 1000000007;
	static long modInv[];
	static int N;
	static long S;
	static long f[];
	static long fact[];
	public static void main(String[] args) {
		JS in = new JS();
		N = in.nextInt();
		S = in.nextLong();
		f = new long[N];
		for(int i = 0; i < N; i++) f[i] = in.nextLong();
		modInv = new long[N+5];
		for(int i = 0; i <= N+4; i++) modInv[i] = pow(i, mod-2);

		long ans = 0;
		for(int i = 0; i < (1<<N); i++) {
			long over = S;
			for(int j = 0; j < N; j++) {
				if((i & (1<<j)) > 0) {
					over -= f[j]+1;
				}
			}
			if(over < 0) continue;
			long v = sumTo(over, N);
			if(Integer.bitCount(i)%2==1) ans -= v;
			else ans += v;
			while(ans < 0) ans+=mod;
			while(ans >= mod)ans-=mod;
		}
		System.out.println(ans);
	}

	static long sumTo(long sum, long n) {
		return choose(sum+n-1, n-1);
	}
	static long choose(long n, long k) {
		long prev = 1;
		for(int c = 1; c <= k; c++)
			prev = (((prev*(n%mod-c+1))%mod)*modInv[c])%mod;
		while(prev < 0) prev += mod;
		while(prev >= mod) prev -= mod;
		return prev;
	}

	static long pow(long base, long power) {
		if(power == 0) return 1;
		if(power == 1) return base;
		if((power%2)==0) {
			long r = pow(base, power/2);
			return (r*r)%mod;
		}
		else {
			return (base * pow(base,power-1))%mod;
		}
	}

	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

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

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

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

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

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

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

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

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int []nia(int n){
			int r[] = new int[n];
			for(int i = 0; i < n; i++) r[i] = nextInt();
			return r;
		}
		public double []nda(int n){
			double r[] = new double[n];
			for(int i = 0; i < n; i++) r[i] = nextDouble();
			return r;
		}
		public long []nla(int n){
			long r[] = new long[n];
			for(int i = 0; i < n; i++) r[i] = nextLong();
			return r;
		}
	}

}


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

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

	void solve()
	{
		int n = ni();
		long s = nl();
		long[] a = new long[n];
		for(int i = 0;i < n;i++)a[i] = nl();
		int mod = 1000000007;
		long ret = 0;
		for(int i = 0;i < 1<<n;i++){ // used
			long sum = 0;
			for(int j = 0;j < n;j++){
				if(i<<31-j<0)sum += a[j]+1;
			}
			long rem = s-sum;
			if(rem < 0)continue;
			long val = 1;
			long N = rem+n-1, R = n-1;
			for(int j = 1;j <= R;j++){
				val = val * ((N-j+1)%mod) % mod * invl(j, mod) % mod;
			}
			if(Integer.bitCount(i) % 2 == 0){
				ret += val;
			}else{
				ret += mod-val;
			}
		}
		out.println(ret%mod);
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

public final class devu_and_flowers
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	static long mod=(long)(1e9+7);

	static long C(long n,long diff)
	{
		long ret=1,upper=n+diff-1;

		for(long x=upper;x>diff;x--)
		{
			long now=x%mod;

			ret=(ret*now)%mod;
		}

		return (ret*pow(fact(n-1),mod-2))%mod;
	}

	static long fact(long n)
	{
		long ret=1;

		for(long i=1;i<=n;i++)
		{
			ret=(ret*i)%mod;
		}

		return ret;
	}

	static long pow(long a,long b)
	{
		long x=1,y=a;

		while(b>0)
		{
			if(b%2==1)
			{
				x=(x*y)%mod;
			}

			y=(y*y)%mod;b=b/2;
		}

		return x;
	}

	static Map<Long,Long> merge(Map<Long,Long> m1,long now)
	{
		Map<Long,Long> m2=new HashMap<>(),ret=new HashMap<>();

		m2.put(0L,1L);m2.put(now,(-1L+mod)%mod);

		for(Map.Entry<Long,Long> en1:m1.entrySet())
		{
			for(Map.Entry<Long,Long> en2:m2.entrySet())
			{
				long add=en1.getKey()+en2.getKey(),mul=(en1.getValue()*en2.getValue())%mod;

				ret.put(add,(ret.getOrDefault(add,0L)+mul)%mod);
			}
		}

		return ret;
	}

    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt();long s=sc.nextLong();

		long[] a=new long[n];

		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextLong();
		}

		// 1-x^a[i]+1..

		Map<Long,Long> m1=new HashMap<>();m1.put(0L,1L);

		for(int i=0;i<n;i++)
		{
			m1=merge(m1,a[i]+1);
		}

		long res=0;

		for(Map.Entry<Long,Long> en:m1.entrySet())
		{
			long curr=en.getKey();

			if(curr<=s)
			{
				long diff=s-curr;

				long now=C(n,diff);

				long mul=(en.getValue()*now)%mod;

				res=(res+mul)%mod;
			}
		}

		out.println(res);out.close();
    }

	private static class Pair
	{
		long pow,cof;

		public Pair(long pow,long cof)
		{
			this.pow=pow;this.cof=cof;
		}
	}
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }

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

	public String next() throws Exception {
		return nextToken().toString();
	}

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

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

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


import java.util.ArrayList;
import java.util.Scanner;

public class e {
	static final long MOD = (long)1e9+7;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long[] invs = new long[25];
		invs[1] = 1;
		for (int i = 2; i < invs.length; ++i)
			invs[i] = (MOD - (MOD / i) * invs[((int) (MOD % i))] % MOD) % MOD;
		int n = in.nextInt();
		long s = in.nextLong();
		long[] fs = new long[n];
		for(int i=0;i<n;i++)
			fs[i] = in.nextLong();
		ArrayList<Term> ans = new ArrayList<>();
		ArrayList<ArrayList<Term>> eqList = new ArrayList<>();
		for(int i=0;i<n;i++) {
			ArrayList<Term> cur = new ArrayList<>();
			cur.add(new Term(1,0));
			cur.add(new Term(-1,fs[i]+1));
			eqList.add(cur);
		}
		multiply(ans, eqList, 0, new Term(1, 0));
		long sum = 0;
		for(Term t : ans) {
			long pow = s - t.pow;
			if(pow < 0) continue;
			long choose = 1;
			for(int i=0;i<n-1;i++) {
				choose *= (pow+n-1-i) % MOD;
				choose %= MOD;
				choose *= invs[i+1];
				choose %= MOD;
			}
			sum += t.c * choose;
			sum %= MOD;
		}
		if(sum < 0) sum += MOD;
		System.out.println(sum);
	}
	static void multiply(ArrayList<Term> ans, ArrayList<ArrayList<Term>> list, int idx, Term current) {
		if(idx == list.size()) {
			ans.add(current);
			return;
		}
		for(Term t : list.get(idx)) {
			Term nt = new Term((t.c * current.c) % MOD, t.pow + current.pow);
			multiply(ans, list, idx+1, nt);
		}
	}
	static class Term {
		long c;
		long pow;
		public Term(long c, long pow) {
			this.c = c;
			this.pow = pow;
		}
	}
}