//package round122;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

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

	void solve()
	{
		int M2 = 1<<13;
		int M5 = 5*5*5*5*5*5*5*5*5*5*5*5*5;

		long f = nl();
		int x2 = (int)(f % M2);
		int[] fa2 = new int[M2];
		int[] a2 = new int[1<<14];
		a2[0] = 0;
		a2[1] = 1;
		Arrays.fill(fa2, -1);
		fa2[0] = 0;
		fa2[1] = 1;
		for(int i = 2;i < 13000;i++){
			a2[i] = (a2[i-1] + a2[i-2]) % M2;
			if(fa2[a2[i]] == -1)fa2[a2[i]] = i;
		}
		if(fa2[x2] == -1){
			out.println(-1);
			return;
		}

		int f5 = (int)(f%5);
		List<Long> l = new ArrayList<Long>();
		{
			int[] a = new int[20];
			a[0] = 0;
			a[1] = 1;
			for(int i = 2;i < 4*5;i++){
				a[i] = (a[i-1] + a[i-2]) % 5;
			}
			for(int i = 0;i < 4*5;i++){
				if(a[i] == f5){
					l.add((long)i);
				}
			}
		}

		int[][] F = {
				{1, 1}, {1, 0}
		};
		for(long m = 25;m <= M5;m*=5){
			int fm = (int)(f % m);
			List<Long> nl = new ArrayList<Long>();
			for(long ll : l){
				for(int k = 0;k < 5;k++){
					long ne = ll+k*4*(m/5);
					long nf = 0;
					if(ne == 0){
						nf = 0;
					}else{
						nf = pow(F, new int[]{1, 0}, ne-1, (int)m)[0];
					}
					if(nf == fm){
						nl.add(ne);
					}
				}
			}
			l = nl;
		}

		long min = Long.MAX_VALUE;
		for(long ll : l){
			for(int i = 0;i < a2.length;i++){
				if(a2[i] == f % M2){
					long num = crtx(new long[]{M2*3/2, 4L*M5}, new long[]{i, ll}).longValue();
					if(num >= 0){
						min = Math.min(min, num);
					}
				}
			}
//			long num = crt(M2*3/2, fa2[x2], 4L*M5, ll);
		}
		if(min == Long.MAX_VALUE){
			out.println(-1);
		}else{
			out.println(min);
		}
	}

	public static long crt(long p, long m, long q, long n)
	{
		long[] apr = exGCD(p, q);
		if((n - m) % apr[0] != 0)return -1;
		long mod = p * q / apr[0];
		long a = (apr[1] * (n - m) / apr[0] * p + m) % mod;
		if(a < 0)a += mod;
		return a;
	}

	// int行列*ベクトル
	public static int[] mul(int[][] A, int[] v, int mod)
	{
		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;
	}

	// int行列の2乗
	public static int[][] p2(int[][] A, int mod)
	{
		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 BigInteger[] exGCD(BigInteger a, BigInteger b)
	{
		BigInteger p = BigInteger.ONE, q = BigInteger.ZERO, r = BigInteger.ZERO, s = BigInteger.ONE;
		while(b.signum() > 0){
			BigInteger c = a.divide(b);
			BigInteger d;
			d = a; a = b; b = d.mod(b);
			d = p; p = q; q = d.subtract(c.multiply(q));
			d = r; r = s; s = d.subtract(c.multiply(s));
		}
		return new BigInteger[]{a, p, r};
	}

	public static BigInteger bi(long x){ return BigInteger.valueOf(x); }

	public static BigInteger crtx(long[] divs, long[] mods)
	{
		BigInteger div = bi(divs[0]), mod = bi(mods[0]);
		for(int i = 1;i < divs.length;i++){
			BigInteger[] apr = exGCD(div, bi(divs[i]));
			BigInteger mm = bi(mods[i]).subtract(mod);
			if(mm.mod(apr[0]).signum() != 0)return bi(-1);
			BigInteger da = div.divide(apr[0]);
			BigInteger ndiv = bi(divs[i]).multiply(da);
			BigInteger nmod = apr[1].multiply(mm).multiply(da).add(mod).mod(ndiv);
			if(nmod.signum() < 0)nmod = nmod.add(ndiv);
			div = ndiv;
			mod = nmod;
		}
		return mod;
	}

	// A^e*v
	public static int[] pow(int[][] A, int[] v, long e, int mod)
	{
		int[][] MUL = A;
		for(;e > 0;e>>>=1) {
			if((e&1)==1)v = mul(MUL, v, mod);
			MUL = p2(MUL, mod);
		}
		return v;
	}

	public static long[] exGCD(long a, long b)
	{
		long p = 1, q = 0, r = 0, s = 1;
		while(b > 0){
			long c = a / b;
			long d;
			d = a; a = b; b = d % b;
			d = p; p = q; q = d - c * q;
			d = r; r = s; s = d - c * s;
		}
		return new long[]{a, p, r};
	}

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

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
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 {
    static final long MODULO = (long) 1e13;

    private long[][] mul(long[][] a, long[][] b, long modulo) {
        long[][] c = new long[2][2];
        for (int i = 0; i < 2; ++i)
            for (int j = 0; j < 2; ++j) {
                BigInteger sum = BigInteger.ZERO;
                for (int k = 0; k < 2; ++k)
                    sum = sum.add(BigInteger.valueOf(a[i][k]).multiply(BigInteger.valueOf(b[k][j])));
                c[i][j] = sum.mod(BigInteger.valueOf(modulo)).longValue();
            }
        return c;
    }

    static class Candidate {
        long offset;
        long[][] trans;

        Candidate(long offset, long[][] trans) {
            this.offset = offset;
            this.trans = trans;
        }
    }

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        long f = in.nextLong();
        long mod = 1;
        long period = 1;
        long[][] mPeriod = new long[][]{new long[]{0, 1}, new long[]{1, 1}};
        List<Candidate> offsets = new ArrayList<Candidate>();
        offsets.add(new Candidate(0, new long[][]{new long[]{1, 0}, new long[]{0, 1}}));
        for (int i = 0; i < 26; ++i) {
            if (i < 13)
                mod *= 2;
            else
                mod *= 5;
            long nperiod = period;
            long[][] nmPeriod = mPeriod;
            while (nmPeriod[0][1] % mod != 0 || nmPeriod[1][1] % mod != 1) {
                nmPeriod = mul(nmPeriod, mPeriod, MODULO);
                nperiod += period;
            }
            List<Candidate> newOffsets = new ArrayList<Candidate>();
            for (Candidate old : offsets) {
                long[][] trans = old.trans;
                for (long noffset = old.offset; noffset < nperiod; noffset += period) {
                    if ((trans[0][1] % mod == f % mod)) {
                        newOffsets.add(new Candidate(noffset, trans));
                    }
                    trans = mul(trans, mPeriod, MODULO);
                }
            }
            offsets = newOffsets;
            period = nperiod;
            mPeriod = nmPeriod;
        }
        long min = Long.MAX_VALUE;
        for (Candidate c : offsets)
            min = Math.min(min, c.offset);
        if (min == Long.MAX_VALUE) out.println(-1); else out.println(min);
	}
}

class InputReader {
    private BufferedReader reader;
    private 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 (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

    }


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

public class D {

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

    final int ROOT = 46300;

    ArrayList<Integer> primes;

    int ind;

    int go(int x, int div, int sign, int lastInd) {
        //System.err.println(x + " " + div + " " + sign + " " + lastInd);
        if (x < div)
            return 0;
        int res = sign * (x / div);
        for (int i = lastInd + 1; i < ind; i++) {
            if (primes.get(i) > x / div)
                break;
            res += go(x, div * primes.get(i), -sign, i);
        }
        return res;
    }

    int go(int x) {
        return go(x, 1, 1, -1);
    }

    void solve() throws IOException {
        int l = nextInt();
        int r = nextInt();
        int k = nextInt();

        boolean[] isPrime = new boolean[ROOT];
        Arrays.fill(isPrime, true);

        primes = new ArrayList<Integer>();

        for (int i = 2; i < ROOT; i++) {
            if (isPrime[i]) {
                primes.add(i);
                for (int j = i * i; j < ROOT; j += i)
                    isPrime[j] = false;
            }
        }

        for (int p : primes) if (k != p && k % p == 0) {
            out.print(0);
            return;
        }

        if (k > ROOT) {
            if (l <= k && k <= r)
                out.print(1);
            else
                out.print(0);
            return;
        }

        ind = Collections.binarySearch(primes, k);

        if (l % k == 0)
            l /= k;
        else
            l = l / k + 1;

        r /= k;

        //System.err.println(go(7));

        out.print(go(r) - go(l - 1));

    }

    void inp() 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 D().inp();
    }

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

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

    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.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 Itpossible
 */
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);
		E solver = new E();
		solver.solve(1, in, out);
		out.close();
	}
}

class E {
    public double[][][][] dp;
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int x = in.nextInt();
        int k = in.nextInt();
        int p = in.nextInt();
        dp = new double[2][256][251][2];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 256; j++) {
                for (int u = 0; u < 251; u++) {
                    dp[i][j][u][0] = 0;
                    dp[i][j][u][1] = 0;
                }
            }
        }
        int y=x/256;
        if(y==0) {
            dp[0][x&255][0][0]=1;
        } else {
            if((y&1)==0) {
                int z=0;
                for(; (y&1)==0; z++) {
                    y>>=1;
                }
                dp[0][x&255][z][0]=1;
            } else {
                int z=0;
                for(; (y&1)>0; z++) {
                    y>>=1;
                }
                dp[0][x&255][z][1]=1;
            }
        }
        for(int i=0; i<k; i++) {

            for(int j=0; j<256; j++) {
                for (int u = 0; u < 250; u++) {
                    dp[(i+1)&1][j][u][0]=0;
                    dp[(i+1)&1][j][u][1]=0;
                }
            }
            for(int j=0; j<256; j++) {
                for(int u=0; u<250; u++) {
                    if((j&128)>0) {
                        dp[(i+1)&1][(j<<1)&255][1][1]+=dp[i&1][j][u][0]*p*0.01;
                        dp[(i+1)&1][(j<<1)&255][u+1][1]+=dp[i&1][j][u][1]*p*0.01;
                    } else {
                        dp[(i+1)&1][(j<<1)&255][u+1][0]+=dp[i&1][j][u][0]*p*0.01;
                        dp[(i+1)&1][(j<<1)&255][1][0]+=dp[i&1][j][u][1]*p*0.01;
                    }
                    if(j==255) {
                        dp[(i+1)&1][0][1][1]+=dp[i&1][j][u][0]*(1-p*0.01);
                        dp[(i+1)&1][0][u][0]+=dp[i&1][j][u][1]*(1-p*0.01);
                    } else {
                        dp[(i+1)&1][j+1][u][0]+=dp[i&1][j][u][0]*(1-p*0.01);
                        dp[(i+1)&1][j+1][u][1]+=dp[i&1][j][u][1]*(1-p*0.01);
                    }
                }
            }
        }
        double ans=0;
        for(int j=0; j<256; j++) {
            int cnt=0;
            if(j>0) {
                for (int t = j; (t & 1) == 0; cnt++) {
                    t >>= 1;
                }
            }
            for(int u=0; u<250; u++) {
                if(j==0) {
                    ans+=dp[k&1][0][u][0]*(8+u);
                    ans+=dp[k&1][0][u][1]*8;
                } else {
                    ans+=dp[k&1][j][u][0]*cnt;
                    ans+=dp[k&1][j][u][1]*cnt;
                }
            }
        }
        out.printf("%.13f\n",ans);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

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

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

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

}


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

public class P1145D {

  private static void solve() {
    int n = nextInt();

    int[] a = new int[n];

    int min = Integer.MAX_VALUE;
    for (int i = 0; i < n; i++) {
      a[i] = nextInt();
      min = Math.min(min, a[i]);
    }

    out.println(2 + (min ^ a[2]));
  }

  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

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

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

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

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


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

public class Test {
    int readInt() {
        int ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    int r, c;
    Scanner sca = new Scanner(System.in);
    long[][] C = new long[64][64];
    long best = Long.MAX_VALUE;

    void dfs(long x, long y, int v1, int v2) {
        long d = Math.abs(x - y);
        if (best <= 1 || d - C[v1][r]*C[v2][r] >= best) return;
        if (v1 == r - 1 && v2 == r - 1) {
            if (d < best) best = d;
            return;
        }
        if (v1 >= r) {
            long c1 = C[v1][r] - C[v1-1][r], s2 = C[v2][r];
            dfs(x, y + c1*s2, v1 - 1, v2);
        }
        if (v2 >= r) {
            long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
            dfs(x + s1*c2, y, v1, v2 - 1);
        }
    }

    int[] cntA = new int[64], cntB = new int[64];
    Map<Long, Long> cache = new TreeMap<>();
    char[] cs;

    long solve(long x, long y, int v1, int v2) {
        long k = x*10000 + v1*100  + v2;
        Long v = cache.get(k);
        if (v != null) return v;
        v = 0l;
        long d = Math.abs(x - y);
        if (d - C[v1][r]*C[v2][r] > best) {
            cache.put(k, v);
            return v;
        }
        if (v1 < r || v2 < r) {
            int sum = v1 + v2;
            if (v1 >= cntA[sum] && v2 >= cntB[sum]) {
                v1 -= cntA[sum];
                v2 -= cntB[sum];
                v = C[v1+v2][v1];
                cache.put(k, v);
                return v;
            }
            cache.put(k, v);
            return v;
        }
        char c = cs[v1 + v2 - 1];
        if (c != 'B') {
            long c1 = C[v1][r] - C[v1 - 1][r], s2 = C[v2][r];
            v += solve(x, y + c1*s2, v1 - 1, v2);
        }
        if (c != 'A') {
            long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
            v += solve( x + s1*c2, y, v1, v2 - 1);
        }
        cache.put(k, v);
        return v;
    }

    void start() {
        r = sca.nextInt(); c = sca.nextInt(); sca.nextLine();
        cs = sca.nextLine().toCharArray();
        for (int i = 0; i <= 2*(r + c); i++)
            for (int j = 0; j <= 2*(r + c); j++) {
                if (j == 0) C[i][j] = 1;
                else if (i == 0) C[i][j] = 0;
                else C[i][j] = C[i-1][j - 1] + C[i - 1][j];
            }
        int v1 = r + c, v2 = r + c;
        long x = 0, y = 0;
        while (v1 >= r && v2 >= r) {
            if (x > y) {
                long c1 = C[v1][r] - C[v1 - 1][r], s2 = C[v2][r];
                y += c1*s2;
                v1--;
            } else {
                long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
                x += s1*c2;
                v2--;
            }
        }
        best = Math.abs(x - y);
        dfs(0, 0, r + c, r + c);
        for (int i = 0; i < 2*(r+c); i++) {
            cntA[i + 1] = cntA[i] + (cs[i] == 'A' ? 1 : 0);
            cntB[i + 1] = cntB[i] + (cs[i] == 'B' ? 1 : 0);
        }
        long ans = solve(0, 0, r + c, r + c);
        System.out.println(ans);
    }

    public static void main(String[] args) {

        new Test().start();

    }
}


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Test {
  static PrintWriter writer =
      new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
  int R, C;
  long[][] ch = new long[61][61];
  int[] cntA = new int[61], cntB = new int[61];
  long best = Long.MAX_VALUE;
  String str;
  Map<Long, Long> cache = new HashMap<>();
  Set<Long> tried = new HashSet<>();

  public static void main(String[] args) {
    Test te = new Test();
    te.start();
    writer.flush();
  }

  static int readInt() {
    int ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static long readLong() {
    long ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static String readString() {
    StringBuilder b = new StringBuilder();
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (!Character.isWhitespace(c)) {
          start = true;
          b.append((char) c);
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return b.toString();
  }

  static int readChars(char[] a, int off) {
    int cnt = 0;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (!Character.isWhitespace(c)) {
          start = true;
          a[off + cnt++] = (char) c;
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return cnt;
  }

  void dfs(long x, long y, int v1, int v2) {
    long diff = Math.abs(x - y);
    if (best <= 1 || diff - ch[v1][R] * ch[v2][R] >= best) return;
    if (v1 == R - 1 && v2 == R - 1) {
      if (diff < best) best = diff;
      return;
    }
    long key = x * 10_000 + v1 * 100 + v2;
    if (tried.contains(key)) return;
    if (v1 >= R) {
      long cur = ch[v1][R] - ch[v1 - 1][R];
      long other = ch[v2][R];
      dfs(x, y + cur * other, v1 - 1, v2);
    }
    if (v2 >= R) {
      long cur = ch[v2][R] - ch[v2 - 1][R];
      long other = ch[v1][R];
      dfs(x + cur * other, y, v1, v2 - 1);
    }
    tried.add(key);
  }

  long solve(long x, long y, int v1, int v2) {
    long diff = Math.abs(x - y);
    if (diff - ch[v1][R] * ch[v2][R] > best) return 0;
    long key = x * 10000 + v1 * 100 + v2;
    Long v = cache.get(key);
    if (v != null) return v;
    if (v1 < R || v2 < R) {
      if (v1 >= cntA[v1 + v2] && v2 >= cntB[v1 + v2]) {
        int sum = v1 + v2;
        v1 -= cntA[sum];
        v2 -= cntB[sum];
        return ch[v1 + v2][v1];
      }
      return 0;
    }
    long ans = 0;
    char c = str.charAt(v1 + v2 - 1);
    if (c != 'B') {
      long cur = ch[v1][R] - ch[v1 - 1][R];
      long other = ch[v2][R];
      ans += solve(x, y + cur * other, v1 - 1, v2);
    }
    if (c != 'A') {
      long cur = ch[v2][R] - ch[v2 - 1][R];
      long other = ch[v1][R];
      ans += solve(x + cur * other, y, v1, v2 - 1);
    }
    cache.put(key, ans);
    return ans;
  }

  void start() {
    R = readInt();
    C = readInt();
    for (int i = 0; i <= 2 * (R + C); i++)
      for (int j = 0; j <= i; j++)
        if (j == 0 || j == i) ch[i][j] = 1;
        else ch[i][j] = ch[i - 1][j - 1] + ch[i - 1][j];
    long x = 0, y = 0;
    int v1 = R + C, v2 = R + C;
    while (v1 >= R && v2 >= R)
      if (x > y) {
        long cur = ch[v1][R] - ch[v1 - 1][R];
        long other = ch[v2][R];
        y += cur * other;
        v1--;
      } else {
        long cur = ch[v2][R] - ch[v2 - 1][R];
        long other = ch[v1][R];
        x += cur * other;
        v2--;
      }
    best = Math.abs(x - y);
    dfs(0, 0, R + C, R + C);
    str = readString();
    for (int i = 0; i < 2 * (R + C); i++) {
      cntA[i + 1] = cntA[i] + (str.charAt(i) == 'A' ? 1 : 0);
      cntB[i + 1] = cntB[i] + (str.charAt(i) == 'B' ? 1 : 0);
    }
    long ans = solve(0, 0, R + C, R + C);
    writer.println(ans);
  }
}


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

public class F {

	long[][] ways;

	static class Half implements Comparable<Half> {
		long match;
		long value;

		public Half(long match, long value) {
			this.match = match;
			this.value = value;
		}

		@Override
		public int compareTo(Half o) {
			return Long.compare(value, o.value);
		}
	}

	boolean nextCombination(int[] a, int n) {
		int k = a.length;
		int ptr = k - 1;
		while (ptr >= 0 && a[ptr] == ptr - k + n) {
			ptr--;
		}
		if (ptr < 0) {
			return false;
		}
		a[ptr]++;
		for (int i = ptr + 1; i < k; i++) {
			a[i] = a[ptr] + i - ptr;
		}
		return true;
	}

	long getWins(char[] s, int r, int c) {
		int curA = 0;
		int curB = 0;
		long ret = 0;
		for (char cc : s) {
			if (cc == 'A') {
				curA++;
			} else {
				ret += choose(curB, r - 1) * choose(curA, r);
				curB++;
			}
		}
		return ret;
	}

	long slow(int r, int c, String s) {
		int[] as = new int[r + c];
		for (int i = 0; i < r + c; i++) {
			as[i] = i;
		}
		long totalWays = ways[r + c][r] * ways[r + c][c];

		char[] buf = new char[2 * (r + c)];

		long bestDiff = Integer.MAX_VALUE;
		long ans = 0;

		List<String> good = new ArrayList<>();

		outer: do {
			Arrays.fill(buf, 'B');
			for (int pos : as) {
				buf[pos] = 'A';
			}
			int match = 1;
			for (int i = 0; i < 2 * (r + c); i++) {
				if (s.charAt(i) != '?' && s.charAt(i) != buf[i]) {
					match = 0;
					break;
				}
			}
			long winsA = getWins(buf, r, c);
			long diff = Math.abs(2 * winsA - totalWays);
			if (diff < bestDiff) {
				bestDiff = diff;
				good.clear();
				if (match == 1)
				good.add(new String(buf));
				ans = match;
			} else if (diff == bestDiff) {
				ans += match;
				if (match == 1)
				good.add(new String(buf));
			}
		} while (nextCombination(as, 2 * (r + c)));
//		System.err.println(good);
		return ans;
	}

	long solve(int r, int c, String s) {

		bestDiff = Long.MAX_VALUE;
		ans = 0;

		long maskA = 0;
		long maskB = 0;
		int[][] cnt = new int[s.length() + 1][2];
		for (int i = 0; i < s.length(); i++) {
			cnt[i + 1] = cnt[i].clone();
			if (s.charAt(i) == 'A') {
				cnt[i + 1][0]++;
				maskA |= 1L << i;
			}
			if (s.charAt(i) == 'B') {
				cnt[i + 1][1]++;
				maskB |= 1L << i;
			}
		}

		long lastA = maskA >> (2 * r + c - 1);
		long lastB = maskB >> (2 * r + c - 1);

		Half[][] fst = new Half[c + 2][];
		Half[][] snd = new Half[c + 2][];
		int[] sz = new int[c + 2];
		for (int i = 0; i < c + 2; i++) {
			sz[i] = (int) ways[c + 1][i];
			fst[i] = new Half[sz[i]];
			snd[i] = new Half[sz[i]];
		}

		for (int mask = 0; mask < 1 << (c + 1); mask++) {
			// 0 - a, 1 - b
			int btc = Integer.bitCount(mask);
			int compBtc = c + 1 - btc;
			int idx = --sz[btc];
			{
				int samePref = Math.min(Integer
						.numberOfTrailingZeros((mask & 1) == 0 ? mask
								: (mask + 1)), c + 1);

				int totalA = r - 1 - cnt[2 * r - 2 + samePref][0];
				int totalB = r - 1 - cnt[2 * r - 2 + samePref][1];
				if ((mask & 1) == 0) {
					totalA += samePref;
				} else {
					totalB += samePref;
				}

				long winsA = 0;

				int curA = 0;
				int curB = 0;
				for (int i = 0; i < c + 1; i++) {
					if (test(mask, i)) {
						winsA += ways[r - 1 + curB][r - 1]
								* choose(r - 1 + curA, r);
						curB++;
					} else {
						curA++;
					}
				}

				// can be optimized into some bit operations
				int exactMatch = 1;
				for (int i = samePref; i < c + 1; i++) {
					if (!test(mask, i) && s.charAt(2 * r - 2 + i) == 'B') {
						exactMatch = 0;
						break;
					}
					if (test(mask, i) && s.charAt(2 * r - 2 + i) == 'A') {
						exactMatch = 0;
						break;
					}
				}

				fst[btc][idx] = new Half(choose(totalA + totalB, totalA)
						* exactMatch, winsA);
			}

			{
				int match = 1;
				if (((~mask) & lastB) != 0) {
					match = 0;
				}
				if ((mask & lastA) != 0) {
					match = 0;
				}

				long winsA = 0;

				int curA = btc;
				int curB = compBtc;
				for (int i = 0; i < c + 1; i++) {
					if (test(mask, i)) {
						winsA += ways[r - 1 + curB][r - 1]
								* choose(r - 1 + curA, r);
						curB++;
					} else {
						curA++;
					}
				}

				snd[btc][idx] = new Half(match, winsA);
			}
		}

		totalWays = ways[r + c][r] * ways[r + c][r];
		long halfTotal = totalWays / 2;

		for (int i = 0; i <= c + 1; i++) {
			Half[] one = compress(fst[i]);
			Half[] two = compress(snd[c + 1 - i]);

			int ptr = two.length - 1;

			for (Half a : one) {
				while (ptr >= 0 && a.value + two[ptr].value > halfTotal) {
					ptr--;
				}
				if (ptr >= 0) {
					update(a, two[ptr]);
				}
				if (ptr + 1 < two.length) {
					update(a, two[ptr + 1]);
				}
			}
		}
		return ans;
	}

	void submit() {
		int r = nextInt();
		int c = nextInt();
		String s = nextToken();
		out.println(solve(r, c, s));
	}

	long totalWays;

	long bestDiff = Long.MAX_VALUE;
	long ans = 0;

	void update(Half a, Half b) {
		long totalValue = a.value + b.value;
		long diff = Math.abs(2 * totalValue - totalWays);
		long delta = a.match * b.match;
		if (diff < bestDiff) {
			bestDiff = diff;
			ans = delta;
		} else if (diff == bestDiff) {
			ans += delta;
		}
	}

	Half[] compress(Half[] arr) {
		Arrays.sort(arr);
		int sz = 1;
		for (int i = 1; i < arr.length; i++) {
			if (arr[i].value == arr[sz - 1].value) {
				arr[sz - 1].match += arr[i].match;
			} else {
				arr[sz++] = arr[i];
			}
		}
		return Arrays.copyOf(arr, sz);
	}

	long choose(int n, int k) {
		return n >= 0 && k >= 0 && k <= n ? ways[n][k] : 0;
	}

	static boolean test(int mask, int i) {
		return ((mask >> i) & 1) == 1;
	}

	void preCalc() {
		ways = new long[61][];
		for (int i = 0; i < ways.length; i++) {
			ways[i] = new long[i + 1];
			ways[i][0] = ways[i][i] = 1;
			for (int j = 1; j < i; j++) {
				ways[i][j] = ways[i - 1][j - 1] + ways[i - 1][j];
			}
		}
	}

	void stress() {
		for (int tst = 0;; tst++) {
			int r = rand(1, 3);
			int c = rand(1, 3);
			char[] buf = new char[2 * (r + c)];
			Arrays.fill(buf, '?');
			String s = new String(buf);
			long fast = solve(r, c, s);
			long slow = slow(r, c, s);
			if (fast != slow) {
				System.err.println(r + " " + c + " " + s);
				System.err.println(fast);
				System.err.println(slow);
				throw new AssertionError();
			}
			System.err.println(tst + " passed");
		}
	}

	void test() {
		int r = 1;
		int c = 3;
		String s = "ABBAABBA";
		System.err.println(solve(r, c, s));
//		System.err.println(slow(r, c, s));
	}

	F() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		 submit();
//		stress();
//		 test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

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

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

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

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

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


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

public class Test {
    int readInt() {
        int ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    int r, c;
    Scanner sca = new Scanner(System.in);
    long[][] C = new long[64][64];
    long best = Long.MAX_VALUE;

    void dfs(long x, long y, int v1, int v2) {
        long d = Math.abs(x - y);
        if (best <= 1 || d - C[v1][r]*C[v2][r] >= best) return;
        if (v1 == r - 1 && v2 == r - 1) {
            if (d < best) best = d;
            return;
        }
        if (v1 >= r) {
            long c1 = C[v1][r] - C[v1-1][r], s2 = C[v2][r];
            dfs(x, y + c1*s2, v1 - 1, v2);
        }
        if (v2 >= r) {
            long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
            dfs(x + s1*c2, y, v1, v2 - 1);
        }
    }

    int[] cntA = new int[64], cntB = new int[64];
    Map<Long, Long> cache = new TreeMap<>();
    char[] cs;

    long solve(long x, long y, int v1, int v2) {
        long k = x*10000 + v1*100  + v2;
        Long v = cache.get(k);
        if (v != null) return v;
        v = 0l;
        long d = Math.abs(x - y);
        if (d - C[v1][r]*C[v2][r] > best) {
            cache.put(k, v);
            return v;
        }
        if (v1 == 0 && v2 == 0) return 1;
        char c = cs[v1 + v2 - 1];
        if (v1 > 0 && c != 'B') {
            long c1 = C[v1][r] - C[v1 - 1][r], s2 = C[v2][r];
            v += solve(x, y + c1*s2, v1 - 1, v2);
        }
        if (v2 > 0 && c != 'A') {
            long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
            v += solve( x + s1*c2, y, v1, v2 - 1);
        }
        cache.put(k, v);
        return v;
    }

    void start() {
        r = sca.nextInt(); c = sca.nextInt(); sca.nextLine();
        cs = sca.nextLine().toCharArray();
        for (int i = 0; i <= 2*(r + c); i++)
            for (int j = 0; j <= 2*(r + c); j++) {
                if (j == 0) C[i][j] = 1;
                else if (i == 0) C[i][j] = 0;
                else C[i][j] = C[i-1][j - 1] + C[i - 1][j];
            }
        int v1 = r + c, v2 = r + c;
        long x = 0, y = 0;
        while (v1 >= r && v2 >= r) {
            if (x > y) {
                long c1 = C[v1][r] - C[v1 - 1][r], s2 = C[v2][r];
                y += c1*s2;
                v1--;
            } else {
                long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
                x += s1*c2;
                v2--;
            }
        }
        best = Math.abs(x - y);
        dfs(0, 0, r + c, r + c);
        for (int i = 0; i < 2*(r+c); i++) {
            cntA[i + 1] = cntA[i] + (cs[i] == 'A' ? 1 : 0);
            cntB[i + 1] = cntB[i] + (cs[i] == 'B' ? 1 : 0);
        }
        long ans = solve(0, 0, r + c, r + c);
        System.out.println(ans);
    }

    public static void main(String[] args) {

        new Test().start();

    }
}


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

public class Test {
  static PrintWriter writer =
      new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
  int R, C;
  long[][] ch = new long[61][61];
  int[] cntA = new int[61], cntB = new int[61];
  long best = Long.MAX_VALUE;
  String str;
  Map<Long, Long> cache = new HashMap<>();

  public static void main(String[] args) {
    Test te = new Test();
    te.start();
    writer.flush();
  }

  static int readInt() {
    int ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static long readLong() {
    long ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static String readString() {
    StringBuilder b = new StringBuilder();
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (Character.isLetterOrDigit(c) || c == '?') {
          start = true;
          b.append((char) c);
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return b.toString();
  }

  static int readChars(char[] a, int off) {
    int cnt = 0;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (Character.isLetterOrDigit(c)) {
          start = true;
          a[off + cnt++] = (char) c;
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return cnt;
  }

  void dfs(long x, long y, int v1, int v2) {
    long diff = Math.abs(x - y);
    if (best <= 1 || diff - ch[v1][R] * ch[v2][R] >= best) return;
    if (v1 == R - 1 && v2 == R - 1) {
      if (diff < best) best = diff;
      return;
    }
    if (v1 >= R) {
      long cur = ch[v1][R] - ch[v1 - 1][R];
      long other = ch[v2][R];
      dfs(x, y + cur * other, v1 - 1, v2);
    }
    if (v2 >= R) {
      long cur = ch[v2][R] - ch[v2 - 1][R];
      long other = ch[v1][R];
      dfs(x + cur * other, y, v1, v2-1);
    }
  }

  long solve(long x, long y, int v1, int v2) {
    long diff = Math.abs(x - y);
    if (diff - ch[v1][R] * ch[v2][R] > best) return 0;
    long key = x*10000 + v1*100 + v2;
    Long v = cache.get(key);
    if (v != null) return v;
    if (v1 < R || v2 < R) {
      if (v1 >= cntA[v1 + v2] && v2 >= cntB[v1 + v2]) {
        int sum = v1 + v2;
        v1 -= cntA[sum];
        v2 -= cntB[sum];
        return ch[v1 + v2][v1];
      }
      return 0;
    }
    long ans = 0;
    char c = str.charAt(v1 + v2 - 1);
    if (c != 'B') {
      long cur = ch[v1][R] - ch[v1 - 1][R];
      long other = ch[v2][R];
      ans += solve(x, y + cur * other, v1 - 1, v2);
    }
    if (c != 'A') {
      long cur = ch[v2][R] - ch[v2 - 1][R];
      long other = ch[v1][R];
      ans += solve(x + cur * other, y, v1, v2 - 1);
    }
    cache.put(key, ans);
    return ans;
  }

  void start() {
    R = readInt();
    C = readInt();
    for (int i = 0; i <= 2*(R + C); i++)
      for (int j = 0; j <= i; j++)
        if (j == 0 || j == i) ch[i][j] = 1;
        else ch[i][j] = ch[i - 1][j - 1] + ch[i - 1][j];
    long x = 0, y = 0;
    int v1 = R + C, v2 = R + C;
    while (v1 >= R && v2 >= R)
      if (x > y) {
        long cur = ch[v1][R] - ch[v1 - 1][R];
        long other = ch[v2][R];
        y += cur * other;
        v1--;
      } else {
        long cur = ch[v2][R] - ch[v2 - 1][R];
        long other = ch[v1][R];
        x += cur * other;
        v2--;
      }
    best = Math.abs(x - y);
    dfs(0, 0, R + C, R + C);
    str = readString();
    for (int i = 0; i < 2 * (R + C); i++) {
      cntA[i + 1] = cntA[i] + (str.charAt(i) == 'A' ? 1 : 0);
      cntB[i + 1] = cntB[i] + (str.charAt(i) == 'B' ? 1 : 0);
    }
    long ans = solve(0, 0, R + C, R + C);
    writer.println(ans);
  }
}


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

public class Test {
    int readInt() {
        int ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    int r, c;
    Scanner sca = new Scanner(System.in);
    long[][] C = new long[64][64];
    long best = Long.MAX_VALUE;

    void dfs(long x, long y, int v1, int v2) {
        long d = Math.abs(x - y);
        if (best <= 1 || d - C[v1][r]*C[v2][r] >= best) return;
        if (v1 == 0 && v2 == 0) {
            if (d < best) best = d;
            return;
        }
        if (v1 > 0) {
            long c1 = C[v1][r] - C[v1-1][r], s2 = C[v2][r];
            dfs(x, y + c1*s2, v1 - 1, v2);
        }
        if (v2 > 0) {
            long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
            dfs(x + s1*c2, y, v1, v2 - 1);
        }
    }

    int[] cntA = new int[64], cntB = new int[64];
    Map<Long, Long> cache = new TreeMap<>();
    char[] cs;

    long solve(long x, long y, int v1, int v2) {
        long k = x*10000 + v1*100  + v2;
        Long v = cache.get(k);
        if (v != null) return v;
        v = 0l;
        long d = Math.abs(x - y);
        if (d - C[v1][r]*C[v2][r] > best) {
            cache.put(k, v);
            return v;
        }
        if (v1 == 0 && v2 == 0) return 1;
        char c = cs[v1 + v2 - 1];
        if (v1 > 0 && c != 'B') {
            long c1 = C[v1][r] - C[v1 - 1][r], s2 = C[v2][r];
            v += solve(x, y + c1*s2, v1 - 1, v2);
        }
        if (v2 > 0 && c != 'A') {
            long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
            v += solve( x + s1*c2, y, v1, v2 - 1);
        }
        cache.put(k, v);
        return v;
    }

    void start() {
        r = sca.nextInt(); c = sca.nextInt(); sca.nextLine();
        cs = sca.nextLine().toCharArray();
        for (int i = 0; i <= 2*(r + c); i++)
            for (int j = 0; j <= 2*(r + c); j++) {
                if (j == 0) C[i][j] = 1;
                else if (i == 0) C[i][j] = 0;
                else C[i][j] = C[i-1][j - 1] + C[i - 1][j];
            }
        int v1 = r + c, v2 = r + c;
        long x = 0, y = 0;
        while (v1 >= r && v2 >= r) {
            if (x > y) {
                long c1 = C[v1][r] - C[v1 - 1][r], s2 = C[v2][r];
                y += c1*s2;
                v1--;
            } else {
                long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
                x += s1*c2;
                v2--;
            }
        }
        best = Math.abs(x - y);
        dfs(0, 0, r + c, r + c);
        for (int i = 0; i < 2*(r+c); i++) {
            cntA[i + 1] = cntA[i] + (cs[i] == 'A' ? 1 : 0);
            cntB[i + 1] = cntB[i] + (cs[i] == 'B' ? 1 : 0);
        }
        long ans = solve(0, 0, r + c, r + c);
        System.out.println(ans);
    }

    public static void main(String[] args) {

        new Test().start();

    }
}


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

public class Test {
  static PrintWriter writer =
      new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
  int R, C;
  long[][] ch = new long[61][61];
  int[] cntA = new int[61], cntB = new int[61];
  long best = Long.MAX_VALUE;
  String str;
  Map<Long, Long> cache = new HashMap<>();

  public static void main(String[] args) {
    Test te = new Test();
    te.start();
    writer.flush();
  }

  static int readInt() {
    int ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static long readLong() {
    long ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static String readString() {
    StringBuilder b = new StringBuilder();
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (!Character.isWhitespace(c)) {
          start = true;
          b.append((char) c);
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return b.toString();
  }

  static int readChars(char[] a, int off) {
    int cnt = 0;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (Character.isLetterOrDigit(c)) {
          start = true;
          a[off + cnt++] = (char) c;
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return cnt;
  }

  void dfs(long x, long y, int v1, int v2) {
    long diff = Math.abs(x - y);
    if (best <= 1 || diff - ch[v1][R] * ch[v2][R] >= best) return;
    if (v1 == R - 1 && v2 == R - 1) {
      if (diff < best) best = diff;
      return;
    }
    if (v1 >= R) {
      long cur = ch[v1][R] - ch[v1 - 1][R];
      long other = ch[v2][R];
      dfs(x, y + cur * other, v1 - 1, v2);
    }
    if (v2 >= R) {
      long cur = ch[v2][R] - ch[v2 - 1][R];
      long other = ch[v1][R];
      dfs(x + cur * other, y, v1, v2-1);
    }
  }

  long solve(long x, long y, int v1, int v2) {
    long diff = Math.abs(x - y);
    if (diff - ch[v1][R] * ch[v2][R] > best) return 0;
    long key = x*10000 + v1*100 + v2;
    Long v = cache.get(key);
    if (v != null) return v;
    if (v1 < R || v2 < R) {
      if (v1 >= cntA[v1 + v2] && v2 >= cntB[v1 + v2]) {
        int sum = v1 + v2;
        v1 -= cntA[sum];
        v2 -= cntB[sum];
        return ch[v1 + v2][v1];
      }
      return 0;
    }
    long ans = 0;
    char c = str.charAt(v1 + v2 - 1);
    if (c != 'B') {
      long cur = ch[v1][R] - ch[v1 - 1][R];
      long other = ch[v2][R];
      ans += solve(x, y + cur * other, v1 - 1, v2);
    }
    if (c != 'A') {
      long cur = ch[v2][R] - ch[v2 - 1][R];
      long other = ch[v1][R];
      ans += solve(x + cur * other, y, v1, v2 - 1);
    }
    cache.put(key, ans);
    return ans;
  }

  void start() {
    R = readInt();
    C = readInt();
    for (int i = 0; i <= 2*(R + C); i++)
      for (int j = 0; j <= i; j++)
        if (j == 0 || j == i) ch[i][j] = 1;
        else ch[i][j] = ch[i - 1][j - 1] + ch[i - 1][j];
    long x = 0, y = 0;
    int v1 = R + C, v2 = R + C;
    while (v1 >= R && v2 >= R)
      if (x > y) {
        long cur = ch[v1][R] - ch[v1 - 1][R];
        long other = ch[v2][R];
        y += cur * other;
        v1--;
      } else {
        long cur = ch[v2][R] - ch[v2 - 1][R];
        long other = ch[v1][R];
        x += cur * other;
        v2--;
      }
    best = Math.abs(x - y);
    dfs(0, 0, R + C, R + C);
    str = readString();
    for (int i = 0; i < 2 * (R + C); i++) {
      cntA[i + 1] = cntA[i] + (str.charAt(i) == 'A' ? 1 : 0);
      cntB[i + 1] = cntB[i] + (str.charAt(i) == 'B' ? 1 : 0);
    }
    long ans = solve(0, 0, R + C, R + C);
    writer.println(ans);
  }
}


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

public class Test {
    int readInt() {
        int ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    int r, c;
    Scanner sca = new Scanner(System.in);
    long[][] C = new long[64][64];
    long best = Long.MAX_VALUE;

    void dfs(long x, long y, int v1, int v2) {
        long d = Math.abs(x - y);
        if (best <= 1 || d - C[v1][r]*C[v2][r] >= best) return;
        if (v1 == 0 && v2 == 0) {
            if (d < best) best = d;
            return;
        }
        if (v1 > 0) {
            long c1 = C[v1][r] - C[v1-1][r], s2 = C[v2][r];
            dfs(x, y + c1*s2, v1 - 1, v2);
        }
        if (v2 > 0) {
            long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
            dfs(x + s1*c2, y, v1, v2 - 1);
        }
    }

    int[] cntA = new int[64], cntB = new int[64];
    Map<Long, Long> cache = new TreeMap<>();
    char[] cs;

    long solve(long x, long y, int v1, int v2) {
        long k = x*10000 + v1*100  + v2;
        Long v = cache.get(k);
        if (v != null) return v;
        v = 0l;
        long d = Math.abs(x - y);
        if (d - C[v1][r]*C[v2][r] > best) {
            cache.put(k, v);
            return v;
        }
        if (v1 == 0 && v2 == 0) return 1;
        char c = cs[v1 + v2 - 1];
        if (v1 > 0 && c != 'B') {
            long c1 = C[v1][r] - C[v1 - 1][r], s2 = C[v2][r];
            v += solve(x, y + c1*s2, v1 - 1, v2);
        }
        if (v2 > 0 && c != 'A') {
            long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
            v += solve( x + s1*c2, y, v1, v2 - 1);
        }
        cache.put(k, v);
        return v;
    }

    void start() {
        r = sca.nextInt(); c = sca.nextInt(); sca.nextLine();
        cs = sca.nextLine().toCharArray();
        for (int i = 0; i <= 2*(r + c); i++)
            for (int j = 0; j <= 2*(r + c); j++) {
                if (j == 0) C[i][j] = 1;
                else if (i == 0) C[i][j] = 0;
                else C[i][j] = C[i-1][j - 1] + C[i - 1][j];
            }
        int v1 = r + c, v2 = r + c;
        long x = 0, y = 0;
        while (v1 > 0 && v2 > 0) {
            if (x > y) {
                long c1 = C[v1][r] - C[v1 - 1][r], s2 = C[v2][r];
                y += c1*s2;
                v1--;
            } else {
                long s1 = C[v1][r], c2 = C[v2][r] - C[v2-1][r];
                x += s1*c2;
                v2--;
            }
        }
        best = Math.abs(x - y);
        dfs(0, 0, r + c, r + c);
        for (int i = 0; i < 2*(r+c); i++) {
            cntA[i + 1] = cntA[i] + (cs[i] == 'A' ? 1 : 0);
            cntB[i + 1] = cntB[i] + (cs[i] == 'B' ? 1 : 0);
        }
        long ans = solve(0, 0, r + c, r + c);
        System.out.println(ans);
    }

    public static void main(String[] args) {

        new Test().start();

    }
}


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

public class Prob03 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] L = new int[N];
        int[] R = new int[N];
        for (int i = 0; i < N; i++) {
            L[i] = in.nextInt();
            R[i] = in.nextInt();
        }
        double[] probabilities = new double[10001];
        for (int i = 0; i < N; i++) {
            for (int j = L[i]; j <= R[i]; j++) {
                double prob = 1./(R[i]-L[i]+1);
                //count probability j to be the second largest
                double probResult = 0;
                outer:
                for (int k = 0; k < N; k++) {
                    if (i == k) continue;

                    double probMax = (1.*R[k] - j)/(R[k]-L[k]+1);
                    if (probMax < 0) continue;
                    if (i < k && L[k]<=j && R[k] >= j)  probMax += 1./(R[k]-L[k]+1);
                    if (probMax > 1) probMax = 1;

                    for (int m = 0; m < N; m++) {
                        if (m==i || m == k) continue;
                        double probMin = (1.*j - L[m])/(R[m]-L[m]+1);
                        if (probMin < 0) continue outer;
                        if (m < i && L[m]<=j && R[m] >= j)  probMin += 1./(R[m]-L[m]+1);
                        if (probMin > 1) probMin = 1;
//                        System.out.println("second: " + j + " max prob: " + probMax + " min prob: " + probMin);
                        probMax *= probMin;
                    }
                    probResult += probMax;
                }
                prob *= probResult;
                probabilities[j] += prob;
//                System.out.println(Arrays.toString(probabilities));
            }
        }

        double sum = 0;
        double prob = 0;
        for (int i = 1; i < 10001; i++) {
            sum += i *probabilities[i];
            prob += probabilities[i];
        }
//        System.out.println(sum);
//        System.out.println(sum / prob);
        System.out.println(String.format("%.9f", sum));
    }

}


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

public class Main {
//	static Scanner in;
	static PrintWriter out;
	static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
//	static BufferedReader in;

	static TreeSet<Long> set = new TreeSet<Long>();
	static int n;
	static int[] x;

	static void count(int[] kol) {
		//System.out.println("!");
	    long a = 0;
		for (int i = 0; i < n; i++) a = a*n + x[i];
		set.add(a);

		int c = 0;
		for (int i = 0; i < n; i++) if (kol[i] > 0) c++;
		if (c < 2) return;

		for (int i = 0; i < n; i++) if (kol[i] > 0) {
			for (int j = i + 1; j < n; j++) if (kol[j] > 0) {
				int[] kol2 = new int[n];
				for (int t = 0; t < n; t++) kol2[t] = kol[t];
				kol2[i]--;
				kol2[j]--;
				int temp = x[i];
				x[i] = x[j];
				x[j] = temp;
				count(kol2);
				temp = x[i];
				x[i] = x[j];
				x[j] = temp;
			}
		}
	}

	public static void main(String[] args) throws Exception {
//		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//		in = new BufferedReader(new InputStreamReader(System.in));

		n = next();

		int[] kol = new int[n];
		for (int i = 0; i < n; i++) kol[i] = next();
		int ones = 0;
		int twos = 0;
		for (int i = 0; i < n; i++)
			if (kol[i] == 1) ones++;
			else twos++;

		int mod = 1000000007;

		long[][] d = new long[n + 1][n + 1];
		int[][] c = new int[n + 1][n + 1];
		for (int i = 0; i <= n; i++) c[i][0] = c[i][i] = 1;
		for (int i = 0; i <= n; i++)
			for (int j = 1; j < i; j++) c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;

		int[] f = new int[n + 1];
		f[0] = 1;
		for (int i = 0; i < n; i++) f[i + 1] = (int)((1L * f[i] * (i + 1)) % mod);

		int[][] a = new int[n + 1][n + 1];
		for (int i = 0; i < n; i++)
			for (int j = 0; j <= i; j++) a[i][j] = (int)(c[i][j] * 1L * f[j] % mod);

		for (int i = 0; i <= ones; i++)
			for (int j = 0; j <= twos; j++) {
				if (i <= 2) d[i][j] = f[i + j];
				else {
					d[i][j] = d[i - 1][j];
					for (int k = 1; k <= j; k++)
						d[i][j] += (a[j][k] * d[i - 1][j - k]) % mod;
					for (int k = 0; k <= j; k++)
						d[i][j] += (i - 1) * a[j][k] * (k + 1) % mod * d[i - 2][j - k] % mod;
					d[i][j] %= mod;
				}
			}

		out.println(d[ones][twos]);

/*		x = new int[n];
		for (int i = 0; i < n; i++) x[i] = i;
		count(kol);

		out.println(set.size());*/

		out.close();
	}
}


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


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

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

    }


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