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

public class Main {

    void solve() {
        int p=ni(),s=ni(),r=ni();
        precompute(100000);
        long ans=0;
        for(int i=r;i<=s;i++){
            for(int j=1;j<=p && i*1L*j<=s;j++){
                long d=mul(C[p-1][j-1],mul(inv[j],go(p-j,s-i*j,i)));
               // pw.println(C[p-1][j-1]+" "+inv[j]+" "+go(p-j,s-i*j,i));
                ans=add(ans,d);
            }
        }
        ans=mul(ans,fact[p-1]);
        ans=mul(ans,fact[s-r]);
        ans=mul(ans,modInverse(fact[s-r+p-1],M));
        pw.println(ans);

    }

    long go(int n,int m,int s){
        if(n==0) {
            if(m>0) return 0;
            else return 1;
        }
        if((s-1)*1L*n<m) return 0;

        long ans=0;
        for(int i=0;i<=n && s*1L*i<=m;i++){
            if(i%2==0)
            ans=add(ans,mul(C[n][i],C[m-s*i+n-1][n-1]));
            else ans=sub(ans,mul(C[n][i],C[m-s*i+n-1][n-1]));
        }
        return ans;
    }
    long fact[];
    int C[][];
    long inv[];
    void precompute(int n){
        C=new int[6001][6001];
        for(int i=0;i<=6000;i++) C[i][0]=1;
        for(int i=1;i<=6000;i++){
            for(int k=1;k<=i;k++) C[i][k]=(int)add(C[i-1][k-1],C[i-1][k]);
        }
        inv=new long[n+1];
        fact=new long[n+1];
        fact[0]=1;
        for(int i=1;i<=n;i++) fact[i]=mul(fact[i-1],i);
        inv[n]=modInverse(fact[n],M);
        for(int i=n-1;i>=0;i--) inv[i]=mul(inv[i+1],i+1);
        inv[1]=1;
        for(int i=2;i<=n;i++){
            inv[i]=mul(inv[i],fact[i-1]);
        }

    }

    long modpow(long a, long b)
    {
        long r=1;
        while(b>0)
        {
            if((b&1)>0) r=mul(r,a);
            a=mul(a,a);
            b>>=1;
        }
        return r;
    }
    long mul(long x,long y){
        x*=y;
        if(x>=M) x%=M;
        return x;
    }
    long add(long x,long y){
        x+=y;
        if(x>=M) x-=M;
        if(x<0) x+=M;
        return x;
    }
    long sub(long x,long y){
        x-=y;
        if(x<0) x+=M;
        return x;
    }
    long modInverse(long A, long M)
    {

        return modpow(A,M-2);
    }

    long M = 998244353;
    InputStream is;
    PrintWriter pw;
    String INPUT = "";

    void run() throws Exception {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
        if (!INPUT.isEmpty()) tr(System.currentTimeMillis() - s + "ms");

    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    private void tr(Object... o) {
        if (INPUT.length() > 0) System.out.println(Arrays.deepToString(o));
    }

}


import java.util.Scanner;

/**
 * Created by WiNDWAY on 6/9/2017.
 */
public class Codeforces_round_416_div_2_VladiskAndCourtesy {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int give = 1;
        while (a >= 0 && b >= 0) {
            if (give % 2 == 1) {
                if (a < give) {
                    System.out.println("Vladik");
                    System.exit(0);
                }
                a -= give;
            } else {
                if (b < give) {
                    System.out.println("Valera");
                    System.exit(0);
                }
                b -= give;
            }
            give++;
        }
    }
}


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

public class cf281b {

    static BufferedReader br;
    static Scanner sc;
    static PrintWriter out;

    public static void initA() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader("input.txt"));
            sc = new Scanner(System.in);
            //out = new PrintWriter("output.txt");
            out = new PrintWriter(System.out);
        } catch (Exception e) {
        }
    }

    public static void initB() {
        try {

            br = new BufferedReader(new FileReader("input.txt"));
            sc = new Scanner(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");

        } catch (Exception e) {
        }
    }

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Integer temp2[] = new Integer[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Integer.parseInt(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static Long[] getLongArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Long temp2[] = new Long[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Long.parseLong(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static String[] getStringArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            String temp2[] = new String[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = (temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static void print(String s, Object... a) {
        out.printf(s, a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static double nextDouble() {
        return sc.nextDouble();
    }

    public static void main(String[] ar) {
        initA();
        solve();
        out.flush();
    }

    public static void solve() {
        Long xxx[] = getLongArr();

        long x = xxx[0];
        long y = xxx[1];
        long n = xxx[2];

        if (y == 1) {
            print("%d/%d\n", x, y);
            return;
        }

        if (n == 1) {
            print("%d/%d\n", x / y, 1);

            return;
        }

        TreeMap<bil, bil> hehe = new TreeMap<bil, bil>(new Comparator<bil>() {

            @Override
            public int compare(bil o1, bil o2) {
                Long a = (o1.x * o2.y) ;
                Long b = (o2.x * o1.y);
                return a.compareTo(b);
            }
        });

        for (long i = n; i >= 1; i--) {

            long tete = i * x;
            long rateOfError = (tete % y);
            long rateOfError2 = (y - rateOfError);
            //print("tete=%d rateError1=%d\n",tete, tete%y);
            if (rateOfError <= rateOfError2) {
                //print("rateError=%d/%d %d/%d\n", rateOfError, i*y, (tete - rateOfError) / y, i);
                hehe.put(new bil(rateOfError, i*y), new bil((tete - rateOfError) / y, i));
            } else {
                //print("rateError2=%d/%d %d/%d\n", rateOfError2, i*y, (tete + rateOfError2) / y, i);
                hehe.put(new bil(rateOfError2, i*y), new bil((tete + rateOfError2) / y, i));
            }
            //print(i+":\t"+rateOfError+" "+rateOfError2);

        }

        bil ou = hehe.get(hehe.firstKey());
        print("%d/%d\n", ou.x, ou.y);

    }

    private static class bil {

        long x, y;

        bil(long x, long y) {
            this.x = x;
            this.y = y;
        }
    }
}


import java .util.Scanner;
public class CodeForces10 {
public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String capital=sc.next();

      /*if(capital.charAt(0)>='A'&&capital.charAt(0)<='Z'){
           System.out.println(capital);
                }else {*/
           capital=(capital.charAt(0)+"").toUpperCase()+capital.substring(1);
           System.out.println(capital);
            }
            }


import java.util.*;
import java.io.*;
public class Solution{
    static Scanner sc;
    static PrintWriter pw;

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

        int t = sc.nextInt();
        while(t-->0)
            solve();

        pw.flush();
        pw.close();
    }
    public static void solve(){
        long a = sc.nextLong(), b = sc.nextLong(), m = sc.nextLong();

        if(a == b){
            pw.println(+1+" "+Long.toString(a));
            return;
        }

        for(int i=1; i<=60; i++){
            long low = (long)Math.pow(2, i-1)*(a+1), high = (long)Math.pow(2, i-1)*(a+m);

            if(low <= b && b<= high){

                if(i == 1){
                    pw.println(+2+" "+a+" "+b);
                    return;
                }

                long k = b - (long)Math.pow(2, i-1)*(a+1);
                //System.out.println(+k+" "+i);

                long arr[] = new long[i+1], sum[] = new long[i+1], step[] = new long[i], fact[] = new long[i];
                arr[0] = a;

                fact[i-1] = 1;
                step[i-1] = 1;
                long q = 1;
                for(int j=i-2; j>=0; j--, q=q*2){
                    step[j] = 1;
                    fact[j] = q;
                }

                for(int j=0; j<i; j++){
                    long p = Math.min(k/fact[j], m-1);
                    step[j] += p;
                    k -= fact[j]*p;
                }

                sum[0] = arr[0];
                for(int j=1; j<=i; j++){
                    //System.out.println(+step[j-1]);
                    arr[j] = sum[j-1] + step[j-1];
                    sum[j] = sum[j-1] + arr[j];
                }

                pw.print(+(i+1)+" ");
                for(long u: arr)
                    pw.print(+u+" ");
                pw.println();
                return;
            }
            else if(low > b)
                break;
        }
        pw.println(-1);
    }
}


import java.util.*;
public class Smallestnumber {
	static long currmin = Long.MAX_VALUE;
	 List<Long> func2(List<Long> numbers,int op, int i,int j)
	{
		long sum= 0;
		List<Long> newwNums = new ArrayList<>();

		if(op=='+')
		{
			sum = numbers.get(i)+numbers.get(j);
		}
		else
		if(op=='*')
		{
			sum = numbers.get(i)*numbers.get(j);
		}

		newwNums.add(sum);
		for(int p=0;p<numbers.size();p++)
		{
			if(p!=i && p!=j)
			{
				newwNums.add(numbers.get(p));
			}
		}
		return newwNums;
	}

	void func1(List<Long> numbers, char[] op,int index)
	{
		if(index==3)
		{
			currmin = Math.min(currmin, numbers.get(0));
			return;
		}
		for(int i=0;i<numbers.size();i++)
		{
			for(int j=i+1;j<numbers.size();j++)
			{
				List<Long> newNums = func2(numbers,op[index],i,j);
				func1(newNums,op,index+1);
			}
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		List<Long> numbers = new ArrayList<>();
		for(int i=0;i<4;i++)
		{
			numbers.add(scan.nextLong());
		}
		char[] op = new char[3];
		for(int i=0;i<3;i++)
		{
			op[i] = scan.next().charAt(0);
		}
		Smallestnumber s = new Smallestnumber();
		int index=0;
		s.func1(numbers,op,index);
		System.out.println(currmin);
	}

}


import java.util.*;
public class SmallerArtemkaAndSurprise
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.println(((n/3)*2) + (n % 3 != 0 ? 1 : 0));
}
}


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

public class Main {

    public static void main(String[] args) throws IOException {
       BufferedReader b= new BufferedReader(new InputStreamReader(System.in));
       String s1=b.readLine();
       String s2=b.readLine();
       StringBuilder sb= new StringBuilder(s1);
       sb.reverse();
       if(sb.toString().equalsIgnoreCase(s2))
            System.out.println("YES");
       else
            System.out.println("NO");
    }}


import java.util.Arrays;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.HashMap;
import java.io.BufferedReader;
import java.util.Map;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 * 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 int MODULO = 10007;
    int magic;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        String s = in.next();
        int n = in.nextInt() + s.length();
        int[][][] ways = new int[s.length()][s.length() + 1][s.length() / 2 + 2];
        int[][] waysAll = new int[3][s.length() / 2 + 2];
        ways[0][s.length()][0] = 1;
        for (int start = 0; start < s.length(); ++start)
            for (int len = s.length() - start; len >= 1; --len) {
                int[] src = ways[start][len];
                if (s.charAt(start) == s.charAt(start + len - 1)) {
                    int nlen = len - 2;
                    int[] dest;
                    if (nlen <= 0) {
                        dest = waysAll[len];
                    } else {
                        dest = ways[start + 1][nlen];
                    }
                    for (int doubles = 0; doubles < src.length; ++doubles) if (src[doubles] != 0) {
                        dest[doubles + 1] = (dest[doubles + 1] + src[doubles]) % MODULO;
                    }
                } else {
                    int nlen = len - 1;
                    int[] dest = ways[start][nlen];
                    for (int doubles = 0; doubles < src.length; ++doubles) if (src[doubles] != 0) {
                        dest[doubles] = (dest[doubles] + src[doubles]) % MODULO;
                    }
                    dest = ways[start + 1][nlen];
                    for (int doubles = 0; doubles < src.length; ++doubles) if (src[doubles] != 0) {
                        dest[doubles] = (dest[doubles] + src[doubles]) % MODULO;
                    }
                }
            }
        int steps = n / 2;
        int ret = 0;
        int maxSingles = s.length();
        int maxDoubles = waysAll[1].length - 1;
        int size = maxSingles + maxDoubles + maxDoubles;
        magic = maxDoubles + maxSingles;
        int[][] m = new int[size][size];
        for (int i = 0; i < maxSingles + maxDoubles + maxDoubles; ++i) {
            if (i + 1 < maxSingles + maxDoubles) m[i + 1][i] = 1;
            if (i >= maxSingles && i < maxSingles + maxDoubles) m[i + maxDoubles][i] = 1;
            m[i][i] = (i < maxSingles ? 24 : (i < maxSingles + maxDoubles ? 25 : 26));
        }
        m = pow(m, steps);
        for (int last = 1; last <= 2; ++last) {
            for (int doubles = 0; doubles < waysAll[last].length; ++doubles) {
                int w = waysAll[last][doubles];
                if (w != 0) {
                    int singles = s.length() + (last == 1 ? 1 : 0) - 2 * doubles;
                    if (n % 2 == 0) {
                        ret = (int) ((ret + (long) w * m[maxSingles + maxDoubles + doubles - 1][maxSingles - singles]) % MODULO);
                    } else {
                        ret = (int) ((ret + (long) w * m[maxSingles + maxDoubles + doubles - 1][maxSingles - singles] * 26) % MODULO);
                        if (last == 1) {
                            ret = (int) ((ret + (long) w * m[maxSingles + doubles - 1][maxSingles - singles]) % MODULO);
                        }
                    }
                }
            }
        }
        out.println(ret);
    }

    private int[][] pow(int[][] m, int k) {
        int[][] res = new int[m.length][m.length];
        for (int i = 0; i < m.length; ++i) res[i][i] = 1;
        while (k > 0) {
            System.err.println(k + " " + m.length);
            if (k % 2 != 0) {
                res = mul(m, res);
            }
            k /= 2;
            m = mul(m, m);
        }
        return res;
    }

    private final int BIG = Integer.MAX_VALUE - Integer.MAX_VALUE % MODULO;

    private int[][] mul(int[][] a, int[][] b) {
        int n = a.length;
        int[][] c = new int[n][n];
        for (int i = 0; i < c.length; ++i) {
            for (int j = 0; j < magic; ++j) {
                int s = 0;
                for (int k = 0; k < magic; ++k) {
                    s += a[i][k] * b[k][j];
                    if (s < 0)
                        s -= BIG;
                }
                if (i >= magic) {
                    int k = i;
                    s += a[i][k] * b[k][j];
                    if (s < 0)
                        s -= BIG;
                }
                c[i][j] = s % MODULO;
            }
            if (i >= magic) {
                int j = i;
                int s = 0;
                for (int k = 0; k < magic; ++k) {
                    s += a[i][k] * b[k][j];
                    if (s < 0)
                        s -= BIG;
                }
                if (i >= magic) {
                    int k = i;
                    s += a[i][k] * b[k][j];
                    if (s < 0)
                        s -= BIG;
                }
                c[i][j] = s % MODULO;
            }
        }
        return c;
    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

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

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

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

}


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

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D2WrongAnswerOnTest233HardVersion solver = new D2WrongAnswerOnTest233HardVersion();
        solver.solve(1, in, out);
        out.close();
    }

    static class D2WrongAnswerOnTest233HardVersion {
        long mod = 998244353;
        long[] factorial;

        public long nCr(int n, int r) {
            return factorial[n] * (CodeHash.modInverse(factorial[n - r], mod) * CodeHash.modInverse(factorial[r], mod) % mod) % mod;
        }

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            long k = in.scanInt();
            long ans = 0;
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) {
                ar[i] = in.scanInt();
            }
            factorial = new long[n + 1];
            factorial[0] = 1;
            for (int i = 1; i <= n; i++) factorial[i] = (factorial[i - 1] * i) % mod;
            int different = 0;
            for (int i = 0; i < n; i++) {
                if (ar[i] != ar[(i + 1) % n]) different++;
            }
            for (int i = 0; i <= different; i++) {
                long ways = nCr(different, i);
                int remaining = different - i;
                if (remaining % 2 == 0) {
                    ways = (ways * ((CodeHash.pow(2, remaining, mod) - nCr(remaining, remaining / 2) + mod) % mod)) % mod;
                    ways = (ways * CodeHash.modInverse(2, mod)) % mod;
                    ways = (ways * CodeHash.pow(k - 2, i, mod)) % mod;
                } else {
                    ways = (ways * CodeHash.pow(2, remaining - 1, mod)) % mod;
                    ways = (ways * CodeHash.pow(k - 2, i, mod)) % mod;
                }
                ans = (ans + ways) % mod;
            }
            out.println((ans * CodeHash.pow(k, n - different, mod)) % mod);

        }

    }

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

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

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

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

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

    }

    static class CodeHash {
        public static long[] euclidExtended(long a, long b) {
            if (b == 0) {
                long ar[] = new long[]{1, 0};
                return ar;
            }
            long ar[] = euclidExtended(b, a % b);
            long temp = ar[0];
            ar[0] = ar[1];
            ar[1] = temp - (a / b) * ar[1];
            return ar;
        }

        public static long modInverse(long a, long m) {
            long ar[] = euclidExtended(a, m);
            return ((ar[0] % m) + m) % m;
        }

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

    }
}


/**
 *
 * @author s3ood
 */
import java.io.IOException;
import java.util.Scanner;
//import java.util.Scanner;

public class Restoring_Password {
    public static void main(String[] args) throws IOException
    {
        Scanner sc = new Scanner(System.in);
        String [] a = new String[10];
        String str = sc.next();
        String out = "";
        for (int i = 0 ;  i<10 ; i++)
        {
            a[i]=""+i+sc.next();
        }
        for (int j=0 ; j<=70 ; j=j+10)
        {
            if (j==70)
                out = out+match(str.substring(j),a);
            else
             out = out+match(str.substring(j, j+10),a);
        }
        System.out.println (out);
    }

    public static char match(String sd , String [] b)
    {
        char c=' ' ;
        for (int u = 0 ; u<b.length ;u++)
        {
            if (sd.matches(b[u].substring(1)))
                c=b[u].charAt(0);
        }
        return c ;

    }

}


import java.util.Scanner;

public class B513 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long m = in.nextLong();

		int arr[] = new int[n];
		int l = 0;
		int r = n - 1;
		int z = n - 2;
		for (int i = 1; i <= n; ++i) {
			long mid = 1l << (z);
			z--;
			if (m > mid) {
				arr[r--] = i;
				m -= mid;
			} else {

				arr[l++] = i;
			}

		}

		for (int i = 0; i < n - 1; ++i) {
			System.out.print(arr[i] + " ");
		}
		System.out.println(arr[n - 1]);

	}
}


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

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

    static class APrimeMinister {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int n = s.nextInt();
            int[] arr = s.nextIntArray(n);
            int sum = 0;
            for (int i = 0; i < n; i++) {
                sum += arr[i];
            }

            int sumTillNow = arr[0];
            StringBuilder ans = new StringBuilder();

            int count = 1;
            for (int i = 0; i < n; i++) {
                if (arr[0] / arr[i] >= 2) {
                    count++;
                }
            }

            ans.append(count).append("\n");
            ans.append(1).append(" ");
            for (int i = 0; i < n; i++) {
                if (arr[0] / arr[i] >= 2) {
                    sumTillNow += arr[i];
                    ans.append(i + 1).append(" ");
                }
            }

            if (sumTillNow < sum / 2 + 1) {
                out.println(0);
            } else {
                out.println(ans);
            }
        }

    }

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

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

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

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

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

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

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

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

        }

    }
}


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

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

	// 1 1 2 4
	// 2 240 151347172

	// 2 16 1536 14155776

	int[] lpf = enumLowestPrimeFactors(1000005);
	int mod = 1000000007;
	int N;

	void solve()
	{
		int n = ni();
		if(n == 1){
			out.println(1);
			return;
		}
		if(n == 3){
			out.println(4);
			return;
		}
		N = n;
		int[] dist = new int[n+1];
		dist[1] = 1;
		int max = 1;
		for(int i = 2;i <= n;i++){
			dist[i] = dist[i/lpf[i]] + 1;
			max = Math.max(max, dist[i]);
		}
		long ans = 0;
		for(int i = 1;i <= n;i++){
			if(dist[i] == max){
				ans += go(i);
			}
		}
		out.println(ans%mod);
	}

	long go(int n)
	{
		int[][] f = factorFast(n, lpf);
		if(f.length == 1){
			assert f[0][0] == 2;
			long[] dp = new long[f[0][1]+1];
			dp[f[0][1]] = 1;
			for(int i = 1;i <= N-1;i++){
				long[] ndp = new long[f[0][1]+1];
				for(int j = 0;j <= f[0][1];j++){
					int nj = j-1;
					if(nj >= 0){
						long can = (N>>>nj) - (N>>>nj+1);
						ndp[nj] += dp[j] * can;
						ndp[nj] %= mod;
					}
					ndp[j] += dp[j] * ((N>>>j)-i);
					ndp[j] %= mod;
				}
				dp = ndp;
			}
			return dp[0];
		}

		assert f.length == 2;
		assert f[0][0] == 2;
		assert f[1][0] == 3;
		assert f[1][1] == 1;
		long[][] dp = new long[2][f[0][1]+1];
		dp[1][f[0][1]] = 1;
		for(int i = 1;i <= N-1;i++){
			long[][] ndp = new long[2][f[0][1]+1];
			for(int k = 0;k < 2;k++){
				for(int j = 0;j <= f[0][1];j++){
					if(dp[k][j] == 0)continue;
					long pre = 1<<j;
					for(int l = 0;l < k;l++)pre *= 3;
					int nj = j-1;
					if(nj >= 0){
						long nex = pre/2;
						long can = N/nex - N/pre;
						ndp[k][nj] += dp[k][j] * can;
						ndp[k][nj] %= mod;
					}
					int nk = k-1;
					if(nk >= 0){
						long nex = pre/3;
						long can = N/nex - N/pre;
						ndp[nk][j] += dp[k][j] * can;
						ndp[nk][j] %= mod;
					}
					if(N/pre-i >= 0){
						ndp[k][j] += dp[k][j] * (N/pre-i);
						ndp[k][j] %= mod;
					}
				}
			}
			dp = ndp;
		}
		return dp[0][0];
//		dfs(n, f);
	}

	public static int[][] enumFIF(int n, int mod) {
		int[] f = new int[n + 1];
		int[] invf = new int[n + 1];
		f[0] = 1;
		for (int i = 1; i <= n; i++) {
			f[i] = (int) ((long) f[i - 1] * i % mod);
		}
		long a = f[n];
		long b = mod;
		long p = 1, q = 0;
		while (b > 0) {
			long c = a / b;
			long d;
			d = a;
			a = b;
			b = d % b;
			d = p;
			p = q;
			q = d - c * q;
		}
		invf[n] = (int) (p < 0 ? p + mod : p);
		for (int i = n - 1; i >= 0; i--) {
			invf[i] = (int) ((long) invf[i + 1] * (i + 1) % mod);
		}
		return new int[][] { f, invf };
	}

	public static int[][] factorFast(int n, int[] lpf)
	{
		int[][] f = new int[9][];
		int q = 0;
		while(lpf[n] > 0){
			int p = lpf[n];
			if(q == 0 || p != f[q-1][0]){
				f[q++] = new int[]{p, 1};
			}else{
				f[q-1][1]++;
			}
			n /= p;
		}
		if(n > 1){
			// big prime
			return new int[][]{{n, 1}};
		}
		return Arrays.copyOf(f, q);
	}

	public static int[] enumLowestPrimeFactors(int n) {
		int tot = 0;
		int[] lpf = new int[n + 1];
		int u = n + 32;
		double lu = Math.log(u);
		int[] primes = new int[(int) (u / lu + u / lu / lu * 1.5)];
		for (int i = 2; i <= n; i++)
			lpf[i] = i;
		for (int p = 2; p <= n; p++) {
			if (lpf[p] == p)
				primes[tot++] = p;
			int tmp;
			for (int i = 0; i < tot && primes[i] <= lpf[p] && (tmp = primes[i] * p) <= n; i++) {
				lpf[tmp] = primes[i];
			}
		}
		return lpf;
	}

	public static int[][] factor(int n, int[] primes)
	{
		int[][] ret = new int[9][2];
		int rp = 0;
		for(int p : primes){
			if(p * p > n)break;
			int i;
			for(i = 0;n % p == 0;n /= p, i++);
			if(i > 0){
				ret[rp][0] = p;
				ret[rp][1] = i;
				rp++;
			}
		}
		if(n != 1){
			ret[rp][0] = n;
			ret[rp][1] = 1;
			rp++;
		}
		return Arrays.copyOf(ret, rp);
	}

	public static int[] sieveEratosthenes(int n) {
		if (n <= 32) {
			int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
			for (int i = 0; i < primes.length; i++) {
				if (n < primes[i]) {
					return Arrays.copyOf(primes, i);
				}
			}
			return primes;
		}

		int u = n + 32;
		double lu = Math.log(u);
		int[] ret = new int[(int) (u / lu + u / lu / lu * 1.5)];
		ret[0] = 2;
		int pos = 1;

		int[] isnp = new int[(n + 1) / 32 / 2 + 1];
		int sup = (n + 1) / 32 / 2 + 1;

		int[] tprimes = { 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
		for (int tp : tprimes) {
			ret[pos++] = tp;
			int[] ptn = new int[tp];
			for (int i = (tp - 3) / 2; i < tp << 5; i += tp)
				ptn[i >> 5] |= 1 << (i & 31);
			for (int j = 0; j < sup; j += tp) {
				for (int i = 0; i < tp && i + j < sup; i++) {
					isnp[j + i] |= ptn[i];
				}
			}
		}

		// 3,5,7
		// 2x+3=n
		int[] magic = { 0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, 31, 22, 28, 18, 26, 10, 7, 12, 21, 17,
				9, 6, 16, 5, 15, 14 };
		int h = n / 2;
		for (int i = 0; i < sup; i++) {
			for (int j = ~isnp[i]; j != 0; j &= j - 1) {
				int pp = i << 5 | magic[(j & -j) * 0x076be629 >>> 27];
				int p = 2 * pp + 3;
				if (p > n)
					break;
				ret[pos++] = p;
				if ((long) p * p > n)
					continue;
				for (int q = (p * p - 3) / 2; q <= h; q += p)
					isnp[q >> 5] |= 1 << q;
			}
		}

		return Arrays.copyOf(ret, pos);
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		int n=s.length();
		System.out.println(26*(n+1)-n);
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.Writer;
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);
        OutputWriter out = new OutputWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {
    static final long mod = 1000000007;
    int[][][] can;
    int[] cnt;
    int[][] a;
    int n, m, k;
    int oq;

    long res = 0;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        n = in.nextInt();
        m = in.nextInt();
        k = in.nextInt();
        if (k < n + m - 1) {
            out.printLine(0);
            return;
        }
        a = new int[n][m];
        cnt = new int[k];
        can = new int[n][m][k];
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < m; ++j) {
                a[i][j] = in.nextInt();
                if (a[i][j] != 0) {
                    if (can[i][j][a[i][j] - 1] > 0) {
                        out.printLine(0);
                        return;
                    }
                    ++cnt[a[i][j] - 1];
                    for (int p = 0; p <= i; ++p)
                        for (int q = 0; q <= j; ++q)
                            can[p][q][a[i][j] - 1]++;
                    for (int p = i; p < n; ++p)
                        for (int q = j; q < m; ++q)
                            can[p][q][a[i][j] - 1]++;
                }
            }
        oq = 0;
        for (int i = 0; i < k; ++i)
            if (cnt[i] != 0) ++oq;
        dfs(0, 0);
        res %= mod;
//        for (int i = 1; i <= k; ++i)
//            res = (res * (long) i) % mod;
        out.printLine(res);
    }

    void dfs(int x, int y) {
        if (x >= n) {
            long cur = 1;
            int cntt = 0;
            for (int i = 0; i < k; ++i) if (cnt[i] != 0) {
                ++cntt;
            }
            cntt -= oq;
            for (int i = 0; i < cntt; ++i)
                cur = (cur * (long)(k - oq - i)) % mod;
            res = (res + cur) % mod;
            return;
        }
        int xx = x, yy = y + 1;
        if (yy == m) {
            xx = x + 1;
            yy = 0;
        }
        if (a[x][y] != 0) {
            dfs(xx, yy);
            return;
        }
        boolean was0 = false;
        for (int c = 0; c < k; ++c) if (can[x][y][c] == 0) {
            if (cnt[c] == 0) {
                if (was0) continue;
                was0 = true;
            }
            ++cnt[c];
            for (int i = x; i < n; ++i)
                for (int j = y; j < m; ++j)
                    ++can[i][j][c];
            dfs(xx, yy);
            for (int i = x; i < n; ++i)
                for (int j = y; j < m; ++j)
                    --can[i][j][c];
            --cnt[c];
        }
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buffer = new byte[10000];
    private int cur;
    private int count;

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

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

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

    public int readSkipSpace() {
        int c;
        do {
            c = read();
        } while (isSpace(c));
        return c;
    }

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

}

class OutputWriter {
    private final PrintWriter writer;

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

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

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

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

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

}


import java.util.Scanner;

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

/**
 *
 * @author Б
 */
public class Luba {
    public static void main(String[] args){
        Scanner in =new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        int max=0;
        int[] f=new int[n];
        int[] list= new int[n];
        for(int i=0;i<n;i++){
            list[i]=in.nextInt();
        }
        for(int i=0;i<n;i++){
            if(k%list[i]==0){
                f[i]=list[i];
                if(max<f[i]){
                    max=f[i];
                }
            }
        }System.out.println(k/max);
}

}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					try {
						if (new File("input.txt").exists())
							System.setIn(new FileInputStream("input.txt"));
					} catch (SecurityException e) {}
					long tm0 = System.currentTimeMillis();
					new Main().run();
					long tm1 = System.currentTimeMillis();
					System.err.println((tm1 - tm0) + " ms");
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

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

	int LCM = 5 * 7 * 8 * 9;
	int[] ind;

	int MAXL = 19;
	int MAXM = 48;
	long[] pow10 = new long [MAXL + 1];
	int[] lcm = new int [MAXM];
	long[] dp = new long [(MAXL + 1) * LCM * MAXM];
	long[] cdp = new long [(MAXL + 1) * LCM * MAXM];
	long[] count = new long [MAXL + 1];
	int[] nextRest = new int [(MAXL + 1) * LCM * 10];
	int[] nextInd = new int [MAXM << 4];
	int lcmCount = 0;

	int M1 = LCM * MAXM;
	int M2 = MAXM;

	int R1 = LCM * 10;
	int R2 = 10;

	void run() throws IOException {
		pow10[0] = 1L;
		for (int l = 1; l < MAXL; l++)
			pow10[l] = pow10[l - 1] * 10L;
		ind = new int [LCM + 1];
		fill(ind, -1);
		for (int i = 0; i < 1024; i++)
			if (lcm(i) != 0)
				if (ind[lcm(i)] == -1) {
					lcm[lcmCount] = lcm(i);
					ind[lcm(i)] = lcmCount++;
				}
		for (int l = 0; l < MAXL; l++)
			for (int r = 0; r < LCM; r++)
				for (int d = 0; d < 10; d++)
					nextRest[(l + 1) * R1 + r * R2 + d] = (int) ((pow10[l] * d + r) % LCM);
		for (int m = 0; m < MAXM; m++)
			for (int d = 0; d < 10; d++)
				nextInd[(m << 4) | d] = d < 2 ? m : ind[lcm(lcm[m], d)];
		dp[0 * M1 + 0 * M2 + 0] = 1L;
		for (int l = 0; l < MAXL; l++)
			for (int r = 0; r < LCM; r++)
				for (int m = 0; m < MAXM; m++)
					if (dp[l * M1 + r * M2 + m] != 0L)
						for (int d = 0; d < 10; d++)
							dp[(l + 1) * M1 + nextRest[(l + 1) * R1 + r * R2 + d] * M2 + nextInd[(m << 4) | d]] += dp[l * M1 + r * M2 + m];

		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		for (int T = nextInt(); T --> 0; )
			out.println(solve(nextLong(), nextLong()));

		out.close();
	}

	long solve(long l, long r) {
		return count(r) - count(l - 1);
	}

	long count(long x) {
		fill(cdp, 0L);
		cdp[0 * M1 + 0 * M2 + 0] = 1L;
		long t = x;
		for (int l = 0; l < MAXL && t > 0L; l++, t /= 10L) {
			int cd = (int) (t % 10L);
			for (int r = 0; r < LCM; r++)
				for (int m = 0; m < MAXM; m++) {
					if (dp[l * M1 + r * M2 + m] != 0L)
						for (int d = 0; d < cd; d++)
							cdp[(l + 1) * M1 + nextRest[(l + 1) * R1 + r * R2 + d] * M2 + nextInd[(m << 4) | d]] += dp[l * M1 + r * M2 + m];
					if (cdp[l * M1 + r * M2 + m] != 0L)
						cdp[(l + 1) * M1 + nextRest[(l + 1) * R1 + r * R2 + cd] * M2 + nextInd[(m << 4) | cd]] += cdp[l * M1 + r * M2 + m];
				}
		}
		long ret = 0L;
		int len = len(x);
		for (int r = 0; r < LCM; r++)
			for (int m = 0; m < MAXM; m++)
				if (m == 0 || r % lcm[m] == 0)
					ret += cdp[len * M1 + r * M2 + m];
		return ret;
	}

	int len(long x) {
		int ret = 0;
		while (x > 0L) {
			ret++;
			x /= 10L;
		}
		return ret;
	}

	int[] lst = new int [10];
	int lcm(int mask) {
		int sz = 0;
		for (int i = 0; i < 10; i++)
			if ((mask | (1 << i)) == mask)
				lst[sz++] = i;
		if (sz == 0)
			return 0;
		int lcm = lst[0];
		for (int i = 1; i < sz; i++)
			lcm = lcm(lcm, lst[i]);
		return lcm;
	}

	int lcm(int a, int b) {
		return a / gcd(a, b) * b;
	}

	int gcd(int a, int b) {
		while (a > 0 && b > 0)
			if (a > b)
				a %= b;
			else
				b %= a;
		return a + b;
	}

	String nextToken() throws IOException {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}

		return st.nextToken();
	}

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

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


import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Locale;
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
 */
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 class Query {
        int kind;
        Vertex v;
        Vertex u;
        int t;
    }

    static class Vertex {
        long s;
        long subtreeSize;
        boolean hasInterestingInSubtree = false;
        long subtreeAnswer;
        long childSquareSum;
        Vertex parent;
        Vertex firstChild;
        Vertex nextSibling;
        Vertex interestingParent;
        Vertex firstInterestingChild;
        Vertex nextInterestingSibling;
        long multiplierForIntermediates;
        long constantForIntermediates;
        long intermediatesSize;
        long boringChildrenSize;
        long boringChildrenSquareSum;
        long boringChildrenAnswer;
        boolean interesting;

        void propagateInteresting() {
            Vertex v = firstChild;
            int numIntChild = 0;
            while (v != null) {
                v.propagateInteresting();
                if (v.hasInterestingInSubtree) ++numIntChild;
                v = v.nextSibling;
            }
            if (numIntChild >= 2) interesting = true;
            if (interesting || numIntChild >= 1) hasInterestingInSubtree = true;
        }

        void init() {
            subtreeSize = 1;
            subtreeAnswer = 0;
            childSquareSum = 0;
            boringChildrenSize = 0;
            boringChildrenAnswer = 0;
            boringChildrenSquareSum = 0;
            Vertex v = firstChild;
            while (v != null) {
                v.init();
                subtreeSize += v.subtreeSize;
                subtreeAnswer += v.subtreeAnswer;
                childSquareSum += v.subtreeSize * (long) v.subtreeSize;
                if (interesting && !v.hasInterestingInSubtree) {
                    boringChildrenSize += v.subtreeSize;
                    boringChildrenAnswer += v.subtreeAnswer;
                    boringChildrenSquareSum += v.subtreeSize * (long) v.subtreeSize;
                }
                v = v.nextSibling;
            }
            subtreeAnswer += (subtreeSize * (long) subtreeSize - childSquareSum) * s;
        }

        public void interestingInit() {
            subtreeSize = 1 + boringChildrenSize;
            subtreeAnswer = boringChildrenAnswer;
            childSquareSum = boringChildrenSquareSum;
            Vertex v = firstInterestingChild;
            while (v != null) {
                v.interestingInit();
                long childSize = v.subtreeSize + v.intermediatesSize;
                subtreeSize += childSize;
                subtreeAnswer += v.subtreeAnswer;
                subtreeAnswer += v.multiplierForIntermediates * v.subtreeSize + v.constantForIntermediates;
                childSquareSum += childSize * (long) childSize;
                v = v.nextInterestingSibling;
            }
            subtreeAnswer += (subtreeSize * (long) subtreeSize - childSquareSum) * s;
        }

        public void initIntermediates() {
            Vertex tmp = this;
            intermediatesSize = 0;
            multiplierForIntermediates = 0;
            constantForIntermediates = 0;
            while (!tmp.parent.interesting) {
                long curExtra = tmp.parent.subtreeSize - tmp.subtreeSize;
                intermediatesSize += curExtra;
                multiplierForIntermediates += 2 * curExtra * (long) tmp.parent.s;
                constantForIntermediates += tmp.parent.subtreeAnswer - tmp.subtreeAnswer - 2 * subtreeSize * (long) (tmp.parent.subtreeSize - tmp.subtreeSize) * tmp.parent.s;
                tmp = tmp.parent;
            }
            interestingParent = tmp.parent;
        }
    }

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        /*char[] buf = new char[100000];
        int size;
        try {
            size = in.reader.read(buf);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        if (size == buf.length) throw new RuntimeException();
        String input = new String(buf, 0, size);
        StringWriter sw1 = new StringWriter();
        PrintWriter pw1 = new PrintWriter(sw1);
        doit(new InputReader(new StringInputStream(input)), pw1, 1);
        pw1.close();
        StringWriter sw2 = new StringWriter();
        PrintWriter pw2 = new PrintWriter(sw2);
        doit(new InputReader(new StringInputStream(input)), pw2, 500);
        pw2.close();
        String s1 = sw1.toString();
        String s2 = sw2.toString();
        if (!s1.equals(s2)) throw new RuntimeException();
        out.print(s1);*/
        doit(in, out, 200);
    }

    private void doit(InputReader in, PrintWriter out, int BUBEN) {
        Locale.setDefault(Locale.US);
        int n = in.nextInt();
        Vertex[] vs = new Vertex[n];
        for (int i = 0; i < n; ++i) vs[i] = new Vertex();
        for (int i = 1; i < n; ++i) {
            vs[i].parent = vs[in.nextInt() - 1];
        }
        for (int i = 0; i < n; ++i) {
            vs[i].s = in.nextInt();
        }
        Vertex root = vs[0];
        int numQueries = in.nextInt();
        Query[] queries = new Query[numQueries];
        for (int i = 0; i < numQueries; ++i) {
            Query query = new Query();
            String ss = in.next();
            if (ss.equals("P")) query.kind = 1; else if (ss.equals("V")) query.kind = 2; else throw new RuntimeException();
            if (query.kind == 1) {
                query.v = vs[in.nextInt() - 1];
                query.u = vs[in.nextInt() - 1];
            } else {
                query.v = vs[in.nextInt() - 1];
                query.t = in.nextInt();
            }
            queries[i] = query;
        }
        double mult = 1.0 / n / n;
        Vertex[] inters = new Vertex[n];
        for (int blockFirst = 0; blockFirst < numQueries; blockFirst += BUBEN) {
            int blockLast = Math.min(numQueries, blockFirst + BUBEN);
            for (Vertex vv : vs) {
                vv.interesting = false;
                vv.hasInterestingInSubtree = false;
            }
            root.interesting = true;
            for (int qid = blockFirst; qid < blockLast; ++qid) {
                Query query = queries[qid];
                if (query.kind == 1) {
                    query.v.interesting = true;
                    if (query.v.parent != null) query.v.parent.interesting = true;
                    query.u.interesting = true;
                    if (query.u.parent != null) query.u.parent.interesting = true;
                } else {
                    query.v.interesting = true;
                }
            }
            for (Vertex vv : vs) {
                vv.firstChild = null;
                vv.nextSibling = null;
            }
            for (Vertex vv : vs) {
                if (vv.parent != null) {
                    vv.nextSibling = vv.parent.firstChild;
                    vv.parent.firstChild = vv;
                }
            }
            root.propagateInteresting();
            int ninters = 0;
            for (Vertex vv : vs) if (vv.interesting) {
                inters[ninters++] = vv;
            }
            root.init();
            for (int i = 0; i < ninters; ++i) {
                Vertex vv = inters[i];
                if (vv.parent != null) vv.initIntermediates();
            }
            if (blockFirst == 0) {
                out.println(String.format("%.12f", root.subtreeAnswer * mult));
            }
            for (int qid = blockFirst; qid < blockLast; ++qid) {
                Query query = queries[qid];
                if (query.kind == 1) {
                    Vertex tmp = query.u;
                    while (tmp != null && tmp != query.v) tmp = tmp.interestingParent;
                    if (tmp == null) {
                        query.v.parent = query.u;
                        query.v.interestingParent = query.u;
                    } else {
                        query.u.parent = query.v;
                        query.u.interestingParent = query.v;
                    }
                } else {
                    query.v.s = query.t;
                }
                for (int i = 0; i < ninters; ++i) {
                    Vertex vv = inters[i];
                    vv.firstInterestingChild = null;
                    vv.nextInterestingSibling = null;
                }
                for (int i = 0; i < ninters; ++i) {
                    Vertex vv = inters[i];
                    if (vv.interestingParent != null) {
                        vv.nextInterestingSibling = vv.interestingParent.firstInterestingChild;
                        vv.interestingParent.firstInterestingChild = vv;
                    }
                }
                root.interestingInit();
                out.println(String.format("%.12f", root.subtreeAnswer * mult));
            }
        }
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

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

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

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

}


import static java.lang.Math.min;

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

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();

		boolean[] visited = new boolean[1 << n];
		visited[1] = true;
		int set = 0;
		for (int i = 1; i < n; i++) {

			ArrayList<Integer> comb = new ArrayList<Integer>();
			for (int j = 0; j < i; j++) for (int k = 0; k <= j; k++) if (a[i] == a[j] + a[k]) {
				comb.add(j);
				comb.add(k);
			}

			for (; set < (1 << i); ++set) if (visited[set]) {
				int b = set;
				for (int s = 0; s < comb.size(); s += 2) {
					int j = comb.get(s);
					int k = comb.get(s+1);
					if ((b >> j & 1) == 1 && ((b >> k) & 1) == 1) {
						{
							int nb = b | (1 << i);
							visited[nb] = true;
						}
						for (int l = 0; l < n; l++) if ((b >> l & 1) == 1) {
							int nb = b | (1 << i);
							nb = nb ^ (1 << l);
							visited[nb] = true;
						}
					}
				}
			}
		}

		int best = n + 1;
		for (; set < (1 << n); set++) if (visited[set]) {
			int b = set;
			best = min(best, Integer.bitCount(b));
		}
		if (best >= n + 1)
			best = -1;
		System.out.println(best);

	}
}


import java.util.Scanner;

public class Main {
	public static boolean MyContain(String Input , String NextContian )
	{
		for (int i =0;i<NextContian.length();i++)
		{
			if (!Input.contains(NextContian.substring(i, i+1)))
			{
				return false;
			}
			else
			{
				int  index = Input.indexOf(NextContian.substring(i,i+1));
				Input = Input.substring(0, index) + Input.substring(index+1);
			}
		}
		return true;
	}
	public static void CheckExist(String Input ,int NextContian,String Number ) {
		if (Input.contains(Number)) //2
		{
			int  IndexOfThis = Input.lastIndexOf(Number);
			boolean check = true ;
			//3
			while (check) {
				if (String.valueOf(NextContian).length()> IndexOfThis)
					break;
				if (MyContain(Input.substring(0, IndexOfThis), String.valueOf(NextContian)))
				{
					System.out.println("YES");
					System.out.println(String.valueOf(NextContian)+Number);
					System.exit(0);
				}
				else if (NextContian>=400)
				{
					break;
				}
				else
				{
					NextContian+=4;
				}
			}
		}

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

		String Input = in.nextLine();

		if (Input.contains("0"))
		{
			System.out.println("YES");
			System.out.println("0");
			System.exit(0);
		}
		else if (Input.contains("8"))
		{
			System.out.println("YES");
			System.out.println("8");
			System.exit(0);
		}

		CheckExist(Input,3,"2");
		CheckExist(Input,2,"4");
		CheckExist(Input,1,"6");
		System.out.println("NO");

		in.close();
	}

}


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

public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader (System.in);
		PrintWriter out = new PrintWriter (System.out);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
	int[][] ans;
	int tot;
	class Line {
		int a,b,c,id;
	};

	public void solve (int TestNumber, InputReader in, PrintWriter out) {
		int n = in.nextInt();
		int k = in.nextInt();
		Line[] road = new Line[n];
		for (int i = 0; i < n; ++i) {
			road[i] = new Line();//initialize is necessary
			road[i].a = in.nextInt();
			road[i].b = in.nextInt();
			road[i].c = in.nextInt();
			road[i].id = i+1;
		}
		ans = new int[k][2];
		tot = -1;
		calc(road, k);
		if (tot == -1) {
			out.println("NO");
			return;
		}
		out.println("YES");
		out.println(k-tot);
		for (int i = tot; i < k; ++i) {
			out.println(ans[i][0] + " " + ans[i][1]);
		}
	}
	//Java 特点，有了.length,就不用记录数组长度了；有了for each: 就不用枚举下标了
	private void calc(Line[] road, int k) {
		if (road.length > k*k) {
			if (k == 0) return;
			double pr = 1.0 - getPr(road.length,k);
			int cnt = 1;
			double s = pr;
			while (s > 1e-10) {
				++cnt;
				s *= pr;
			}
			Random rand = new Random(19950315L + System.currentTimeMillis());
			for ( ;cnt > 0; --cnt) {
				Line p = road[rand.nextInt(road.length)];
				Line q = road[rand.nextInt(road.length)];
				int denom = p.a*q.b-p.b*q.a;
				if (denom == 0) continue;
				int x = -(p.c*q.b-p.b*q.c);
				int y = -(p.a*q.c-p.c*q.a);

				int num = 0;
				for (Line r : road) {
					if (r.a*x+r.b*y+r.c*denom == 0) ++num;
				}
				if (num > k) {
					ans[k-1][0] = p.id;
					ans[k-1][1] = q.id;
					int t_tot = 0;
					Line[] n_road = new Line[road.length - num];
					for (Line r : road) {
						if (r.a*x+r.b*y+r.c*denom != 0) {
							n_road[t_tot++] = r;
						}
					}
					calc(n_road, k-1);
					return;
				}
			}
		}
		else if (road.length == 0) {
			tot = k;
		}
		else {
			Random rand = new Random(19950315L + System.currentTimeMillis());
			Line p = road[rand.nextInt(road.length)];
			boolean[] mark = new boolean[road.length];
			Arrays.fill(mark, false);
			boolean any = false;
			for (int i = 0; i < road.length; ++i) {
				if (mark[i]) continue;
				Line q = road[i];
				int denom = p.a*q.b-p.b*q.a;
				if (denom == 0) continue;
				any = true;
				int x = -(p.c*q.b-p.b*q.c);
				int y = -(p.a*q.c-p.c*q.a);

				int num = 0;
				for (int j = 0; j < road.length; ++j) {
					Line r = road[j];
					if (r.a*x+r.b*y+r.c*denom == 0) {
						++num;
						mark[j] = true;
					}
				}
				Line[] n_road = new Line[road.length - num];
				ans[k-1][0] = p.id;
				ans[k-1][1] = q.id;
				int n_tot = 0;
				for (Line r : road) {
					if (r.a*x+r.b*y+r.c*denom != 0) {
						n_road[n_tot++] = r;
					}
				}
				calc(n_road, k-1);
				if (tot > -1) return;
			}
			if (!any) {
				ans[k-1][0] = p.id;
				ans[k-1][1] = -1;
				Line[] n_road = new Line[road.length - 1];
				int n_tot = 0;
				for (Line r : road) {
					if (r != p) {
						n_road[n_tot++] = r;
					}
				}
				calc(n_road, k-1);
			}
		}
	}

	private double getPr(int n, int k) {
		long ret = Long.MAX_VALUE;
		for (int small = 0; small < k; ++small) {
			int rem = n - small * k;
			int big = k - small;
			long pair = 0;
			for (int id = 0; id < big; ++id) {
				long size = rem / big;//size 得 long不能 int
				if (rem % big > id) ++size;
				pair += size*(size-1);
			}
			ret = Math.min(ret, pair);
		}
		return (double)ret/n/n;
	}
}

class InputReader {
	BufferedReader reader;
	StringTokenizer tokenizer;

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

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

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


import java.io.BufferedReader;
import java.io.FileReader;
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.StringTokenizer;

public class B {

	static ArrayList<Edge>[] adjList;
	static int extra, f[], memo[][][];

	static int dp(int t, int u, int k)
	{
		if(k == 0)
			return 0;
		if(memo[t][u][k] != -1)
			return memo[t][u][k];
		int ret = 0;
		for(Edge e: adjList[u])
			ret = Math.max(ret, e.w + dp(t, e.v, k - 1));
		if(t == 0)
			ret = Math.max(ret, f[u] * extra + dp(1, u, k));
		return memo[t][u][k] = ret;
	}

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

		int n = sc.nextInt(), t = sc.nextInt(), A[] = new int[n];
		for(int i = 0; i < n; ++i)
			A[i] = sc.nextInt();
		adjList = new ArrayList[301];
		for(int i = 0; i <= 300; ++i)
			adjList[i] = new ArrayList<Edge>();

		f = new int[301];
		for(int i = 0; i < n; ++i)
			if(f[A[i]]++ == 0)
			{
				int[] L = lis(A, n, A[i]);
				for(int j = 0; j < n; ++j)
					if(L[j] != 0)
						adjList[A[i]].add(new Edge(A[j], L[j]));
			}

		memo = new int[2][301][301];
		for(int[][] x1: memo)
			for(int[] x2: x1)
				Arrays.fill(x2, -1);
		int ans = 0, p = Math.min(t, 300);
		extra = t - p;
		for(int x: A)
			ans = Math.max(ans, dp(0, x, p));
		out.println(ans);
		out.flush();
		out.close();
	}

	static int[] lis(int[] A, int len, int lim)
	{
		int[] L = new int[len];
		for(int i = 0; i < len; ++i)
			if(A[i] >= lim)
			{
				int curL = 1;
				for(int j = 0; j < i; ++j)
					if(A[j] <= A[i] && L[j] + 1 > curL)
						curL = L[j] + 1;
				L[i] = curL;
			}
		return L;
	}

	static class Edge { int v, w; Edge(int a, int b) { v = a; w = b; } public String toString() { return v + " " + w; }}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

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

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

		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 { return Double.parseDouble(next()); }

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

	}
}


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

public class A {
	BufferedReader in;
	StringTokenizer str;
	PrintWriter out;
	String SK;

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

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

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

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

	long big(long l) {
		if (l == 0)
			return 9;
		long res = 0;
		while (l > 0) {
			res = res * 10 + 9;
			l /= 10;
		}
		return res;
	}

	Random st = new Random();

	void solve() throws IOException {
		long l = nextLong();
		long r = nextLong();
		long res = Math.max(l * big(l) - l * l, r * big(r) - r * r);
		long stp = 1;
		long resul = 0;
		for (int i = 0; i < 12; i++) {
			long max = big(stp) / 2;
			if (stp > r)
				break;
			max -= 100;
			for (int j = 1; j <= 400; j++) {
				max++;
				if ((max >= l) && (max <= r) && (max > stp)) {
					res = Math.max(res, max * (big(stp) - max));
				}
			}
			stp *= 10;
		}
		out.println(res);
	};

	void run() throws IOException {

		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

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

}


import java.util.*;
import java.io.*;
public class Main{
	static PrintWriter out=new PrintWriter(System.out);
	public static void main(String [] args) throws IOException{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int z=sc.nextInt();
		int a=0;
		int b=0;
		int d=0;
		for(int i=1;i<=z;i++) {
			if(i%n==0)
				a+=n;
			if (i%m==0)
				b+=m;
			if(a==b&&a!=0&&b!=0) {
				d++;
				a=0;
				b=0;

			}}
		out.println(d);
		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 boolean ready() throws IOException {
			return br.ready();
		}

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

	}
}


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

public class BetaRound71_A implements Runnable {

        final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
        BufferedReader in;
        PrintWriter out;
        StringTokenizer tok = new StringTokenizer("");

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

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

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

        @Override
        public void run() {
                try {
                        long t1 = System.currentTimeMillis();
                        init();
                        Locale.setDefault(Locale.US);
                        solve();
                        out.close();
                        long t2 = System.currentTimeMillis();
                        System.err.println("Time = " + (t2 - t1));
                } catch (Exception e) {
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }

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

        void solve() throws IOException {
                int x = readInt();
                int y = readInt();
                boolean Ciel = true;
                while (true) {
                        boolean b = false;
                        if (Ciel) {
                                for (int d = 2; d >= 0; d--) {
                                        if (x < d) continue;
                                        if (d == 2) {
                                                if (y < 2) {
                                                        out.print("Hanako");
                                                        return;
                                                } else {
                                                        x -= 2;
                                                        y -= 2;
                                                        Ciel = !Ciel;
                                                        b = true;
                                                        break;
                                                }
                                        }
                                        if (d == 1) {
                                                if (y < 12) {
                                                        out.print("Hanako");
                                                        return;
                                                } else {
                                                        x--;
                                                        y -= 12;
                                                        Ciel = !Ciel;
                                                        b = true;
                                                        break;
                                                }
                                        }
                                        if (d == 0) {
                                                if (y < 22) {
                                                        out.print("Hanako");
                                                        return;
                                                } else {
                                                        y -= 22;
                                                        Ciel = !Ciel;
                                                        b = true;
                                                        break;
                                                }
                                        }
                                }
                        } else {
                                for (int d = 22; d >= 0; d -= 10) {
                                        if (y < d) continue;
                                        if (d == 22) {
                                                if (x < 0) {
                                                        out.print("Ciel");
                                                        return;
                                                } else {
                                                        y -= 22;
                                                        Ciel = !Ciel;
                                                        b = true;
                                                        break;
                                                }
                                        }
                                        if (d == 12) {
                                                if (x < 1) {
                                                        out.print("Ciel");
                                                        return;
                                                } else {
                                                        x--;
                                                        y -= 12;
                                                        Ciel = !Ciel;
                                                        b = true;
                                                        break;
                                                }
                                        }
                                        if (d == 2) {
                                                if (x < 2) {
                                                        out.print("Ciel");
                                                        return;
                                                } else {
                                                        x -= 2;
                                                        y -= 2;
                                                        Ciel = !Ciel;
                                                        b = true;
                                                        break;
                                                }
                                        }
                                }
                        }
                        if (!b) {
                                if (Ciel) out.print("Hanako"); else out.print("Ciel");
                                return;
                        }
                }
        }

}


import java.lang.*;
import java.util.*;
public class A1
{
    public static void main(String s[])
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();

		int x = 5;
		int ans = 0;

		ans = ans+a/x;
		a = a%x;

		if(a==0)
		System.out.println(ans);

		else
		System.out.println(ans+1);

    }
}


//package round712;
import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Queue;

public class E3 {
	InputStream is;
	FastWriter out;
	String INPUT = "";
	final int mod = 998244353;
	long[][] C;

	void solve()
	{
		C = new long[4052 + 1][4052 + 1];
		for (int i = 0; i <= 4052; i++) {
			C[i][0] = 1;
			for (int j = 1; j <= i; j++) {
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
				if (C[i][j] >= mod) C[i][j] -= mod;
			}
		}

		int H = ni(), W = ni();

		long T = 0;
		// O(wh^4)
		for(int w = 1;w < W;w++) {
			long R = 0;
			for (int hl = 1; hl <= H; hl++) {
				// 0 <= hr <= H-1-hl
				// d(hl, w-1) * d(hr, w-1)
				// C[dr+w-1][w-1] * d(hl, w-1)
				int hll = H+1 - hl;
				R += d(hll, W-w-1) * C[H-1-hll+W-w][W-w];
				R %= mod;
				T += d(hl, w-1) * C[H-1-hl+w][w] % mod * R;
				T %= mod;
//				for (int hll = 0; hll <= H; hll++) {
//					if (hl + hll > H) {
//						T += d(hl, w-1) * C[H-1-hl+w][w] * d(hll, W-w-1) * C[H-1-hll+W-w][W-w];
//						T %= mod;
//					}
//				}
			}
		}
		T = T * 2;

		long IT = 0;
		// O(hw^4)
		for(int h = 1;h <= H-1;h++){
			// C[h-1+l][l]
			// C[h-1+r][r-1]
			long R = 0;
			for(int r = W-1;r >= 1;r--){
				R += d(H-h-1, r) * C[H-h+W-(r+1)][W-(r+1)];
				R %= mod;
				IT += C[h-1+r][r-1] * d(h-1, W-r) % mod * R;
				IT %= mod;
			}
		}
		IT *= 2;
		out.println((T+IT)%mod);
	}

	long d(int h, int w)
	{
		// begin:h, dec
		return C[h+w][h];
	}

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

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

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

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

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

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

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

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

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

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

	private long[] nal(int n)
	{
		long[] a = new long[n];
		for(int i = 0;i < n;i++)a[i] = nl();
		return a;
	}

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

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

	private int ni() { return (int)nl(); }

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

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

	public static class FastWriter
	{
		private static final int BUF_SIZE = 1<<13;
		private final byte[] buf = new byte[BUF_SIZE];
		private final OutputStream out;
		private int ptr = 0;

		private FastWriter(){out = null;}

		public FastWriter(OutputStream os)
		{
			this.out = os;
		}

		public FastWriter(String path)
		{
			try {
				this.out = new FileOutputStream(path);
			} catch (FileNotFoundException e) {
				throw new RuntimeException("FastWriter");
			}
		}

		public FastWriter write(byte b)
		{
			buf[ptr++] = b;
			if(ptr == BUF_SIZE)innerflush();
			return this;
		}

		public FastWriter write(char c)
		{
			return write((byte)c);
		}

		public FastWriter write(char[] s)
		{
			for(char c : s){
				buf[ptr++] = (byte)c;
				if(ptr == BUF_SIZE)innerflush();
			}
			return this;
		}

		public FastWriter write(String s)
		{
			s.chars().forEach(c -> {
				buf[ptr++] = (byte)c;
				if(ptr == BUF_SIZE)innerflush();
			});
			return this;
		}

		private static int countDigits(int l) {
			if (l >= 1000000000) return 10;
			if (l >= 100000000) return 9;
			if (l >= 10000000) return 8;
			if (l >= 1000000) return 7;
			if (l >= 100000) return 6;
			if (l >= 10000) return 5;
			if (l >= 1000) return 4;
			if (l >= 100) return 3;
			if (l >= 10) return 2;
			return 1;
		}

		public FastWriter write(int x)
		{
			if(x == Integer.MIN_VALUE){
				return write((long)x);
			}
			if(ptr + 12 >= BUF_SIZE)innerflush();
			if(x < 0){
				write((byte)'-');
				x = -x;
			}
			int d = countDigits(x);
			for(int i = ptr + d - 1;i >= ptr;i--){
				buf[i] = (byte)('0'+x%10);
				x /= 10;
			}
			ptr += d;
			return this;
		}

		private static int countDigits(long l) {
			if (l >= 1000000000000000000L) return 19;
			if (l >= 100000000000000000L) return 18;
			if (l >= 10000000000000000L) return 17;
			if (l >= 1000000000000000L) return 16;
			if (l >= 100000000000000L) return 15;
			if (l >= 10000000000000L) return 14;
			if (l >= 1000000000000L) return 13;
			if (l >= 100000000000L) return 12;
			if (l >= 10000000000L) return 11;
			if (l >= 1000000000L) return 10;
			if (l >= 100000000L) return 9;
			if (l >= 10000000L) return 8;
			if (l >= 1000000L) return 7;
			if (l >= 100000L) return 6;
			if (l >= 10000L) return 5;
			if (l >= 1000L) return 4;
			if (l >= 100L) return 3;
			if (l >= 10L) return 2;
			return 1;
		}

		public FastWriter write(long x)
		{
			if(x == Long.MIN_VALUE){
				return write("" + x);
			}
			if(ptr + 21 >= BUF_SIZE)innerflush();
			if(x < 0){
				write((byte)'-');
				x = -x;
			}
			int d = countDigits(x);
			for(int i = ptr + d - 1;i >= ptr;i--){
				buf[i] = (byte)('0'+x%10);
				x /= 10;
			}
			ptr += d;
			return this;
		}

		public FastWriter write(double x, int precision)
		{
			if(x < 0){
				write('-');
				x = -x;
			}
			x += Math.pow(10, -precision)/2;
			//		if(x < 0){ x = 0; }
			write((long)x).write(".");
			x -= (long)x;
			for(int i = 0;i < precision;i++){
				x *= 10;
				write((char)('0'+(int)x));
				x -= (int)x;
			}
			return this;
		}

		public FastWriter writeln(char c){
			return write(c).writeln();
		}

		public FastWriter writeln(int x){
			return write(x).writeln();
		}

		public FastWriter writeln(long x){
			return write(x).writeln();
		}

		public FastWriter writeln(double x, int precision){
			return write(x, precision).writeln();
		}

		public FastWriter write(int... xs)
		{
			boolean first = true;
			for(int x : xs) {
				if (!first) write(' ');
				first = false;
				write(x);
			}
			return this;
		}

		public FastWriter write(long... xs)
		{
			boolean first = true;
			for(long x : xs) {
				if (!first) write(' ');
				first = false;
				write(x);
			}
			return this;
		}

		public FastWriter writeln()
		{
			return write((byte)'\n');
		}

		public FastWriter writeln(int... xs)
		{
			return write(xs).writeln();
		}

		public FastWriter writeln(long... xs)
		{
			return write(xs).writeln();
		}

		public FastWriter writeln(char[] line)
		{
			return write(line).writeln();
		}

		public FastWriter writeln(char[]... map)
		{
			for(char[] line : map)write(line).writeln();
			return this;
		}

		public FastWriter writeln(String s)
		{
			return write(s).writeln();
		}

		private void innerflush()
		{
			try {
				out.write(buf, 0, ptr);
				ptr = 0;
			} catch (IOException e) {
				throw new RuntimeException("innerflush");
			}
		}

		public void flush()
		{
			innerflush();
			try {
				out.flush();
			} catch (IOException e) {
				throw new RuntimeException("flush");
			}
		}

		public FastWriter print(byte b) { return write(b); }
		public FastWriter print(char c) { return write(c); }
		public FastWriter print(char[] s) { return write(s); }
		public FastWriter print(String s) { return write(s); }
		public FastWriter print(int x) { return write(x); }
		public FastWriter print(long x) { return write(x); }
		public FastWriter print(double x, int precision) { return write(x, precision); }
		public FastWriter println(char c){ return writeln(c); }
		public FastWriter println(int x){ return writeln(x); }
		public FastWriter println(long x){ return writeln(x); }
		public FastWriter println(double x, int precision){ return writeln(x, precision); }
		public FastWriter print(int... xs) { return write(xs); }
		public FastWriter print(long... xs) { return write(xs); }
		public FastWriter println(int... xs) { return writeln(xs); }
		public FastWriter println(long... xs) { return writeln(xs); }
		public FastWriter println(char[] line) { return writeln(line); }
		public FastWriter println(char[]... map) { return writeln(map); }
		public FastWriter println(String s) { return writeln(s); }
		public FastWriter println() { return writeln(); }
	}

	public void trnz(int... o)
	{
		for(int i = 0;i < o.length;i++)if(o[i] != 0)System.out.print(i+":"+o[i]+" ");
		System.out.println();
	}

	// print ids which are 1
	public void trt(long... o)
	{
		Queue<Integer> stands = new ArrayDeque<>();
		for(int i = 0;i < o.length;i++){
			for(long x = o[i];x != 0;x &= x-1)stands.add(i<<6|Long.numberOfTrailingZeros(x));
		}
		System.out.println(stands);
	}

	public void tf(boolean... r)
	{
		for(boolean x : r)System.out.print(x?'#':'.');
		System.out.println();
	}

	public void tf(boolean[]... b)
	{
		for(boolean[] r : b) {
			for(boolean x : r)System.out.print(x?'#':'.');
			System.out.println();
		}
		System.out.println();
	}

	public void tf(long[]... b)
	{
		if(INPUT.length() != 0) {
			for (long[] r : b) {
				for (long x : r) {
					for (int i = 0; i < 64; i++) {
						System.out.print(x << ~i < 0 ? '#' : '.');
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}

	public void tf(long... b)
	{
		if(INPUT.length() != 0) {
			for (long x : b) {
				for (int i = 0; i < 64; i++) {
					System.out.print(x << ~i < 0 ? '#' : '.');
				}
			}
			System.out.println();
		}
	}

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


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

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

    static class TaskD {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int k = in.nextInt();
            long ans = 0;
            int l = 0, u = 0;
            Hexagon L = new Hexagon(), U = new Hexagon();
            L.EL();
            U.EL();
            for (int layer = 1; ; layer++) {
                while (!L.distance(k) && l <= u) {
                    L.RL();
                    l++;
                }
                if (l > u) break;
                while (!U.distance(k)) {
                    U.RU();
                    u--;
                }
                ans += u - l + 1;
                u++;
                L.EL();
                U.EU();
            }
            ans = 6 * ans + 1;
            out.println(ans);
        }

        class Hexagon {
            static final int N = 6;
            int[] X;
            int[] Y;

            Hexagon() {
                X = new int[]{2, 1, -1, -2, -1, 1};
                Y = new int[]{0, 1, 1, 0, -1, -1};
            }

            boolean distance(int d) {
                long max = Long.MIN_VALUE;
                for (int i = 0; i < N; i++) max = Math.max(max, (long) X[i] * X[i] + (long) 3 * Y[i] * Y[i]);
                return max <= (long) 4 * d * d;
            }

            void EL() {
                for (int i = 0; i < N; i++) {
                    X[i] += 3;
                    Y[i]++;
                }
            }

            void EU() {
                for (int i = 0; i < N; i++) Y[i] += 2;
            }

            void RL() {
                for (int i = 0; i < N; i++) {
                    X[i] -= 3;
                    Y[i]++;
                }
            }

            void RU() {
                for (int i = 0; i < N; i++) {
                    X[i] += 3;
                    Y[i]--;
                }
            }

        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(new BufferedOutputStream(outputStream));
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

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

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                st = new StringTokenizer(nextLine());
            }
            return st.nextToken();
        }

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

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

    }
}


import java.util.Scanner;
public class Cakeminator {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.nextLine();
		int cnt=0;

		for (int i=0;i<26;i++){
			if(s.indexOf('a'+i)!=-1)
				cnt++;
		}
		System.out.println(cnt%2==1?"IGNORE HIM!":"CHAT WITH HER!");

	}
}


import java.util.*;

public class C {
/*
9
NNSESENN
NNSSWNWN

9
NNSESENN
SNSSWNWN

9
NNSESENN
NNSSWNEN
*/

	public static void main(String[] args) {

		Scanner qwe = new Scanner(System.in);

		int n = qwe.nextInt();
		StringBuilder needle = new StringBuilder(qwe.next()).reverse();
		char[] tocomp = qwe.next().toCharArray();

		StringBuilder hay = new StringBuilder();

		String dirs = "NSEW";
		String dc =   "SNWE";

		for (int i = 0; i < tocomp.length; i++) {
			hay.append(dc.charAt(dirs.indexOf(tocomp[i])));
		}

		if(n == 2){
			if(hay.toString().equals(needle.toString())){
				System.out.println("NO");
			}
			else System.out.println("YES");
		}
		else if(new KMP().KMPSearch(needle.toString(), hay.toString())){
			System.out.println("YES");
		}
		else System.out.println("NO");

		qwe.close();
	}

	static class KMP {
		/**
		 * Generates the table used by KMP. Not really useful on its own :( O(m)
		 * [m=length of needle]
		 */
		public int[] KMPTableGen(String needle) {
			int[] T = new int[needle.length()];
			int pos = 2;
			int cnd = 0;
			T[0] = -1;
			T[1] = 0;
			while (pos < needle.length()) {
				if (needle.charAt(pos - 1) == needle.charAt(cnd)) {
					cnd++;
					T[pos] = cnd;
					pos++;
				} else if (cnd > 0)
					cnd = T[cnd];
				else {
					T[pos] = 0;
					pos++;
				}
			}
			return T;
		}

		/**
		 * KMP - String Searching
		 *
		 * O(n+m) [n=length of haystack, m=length of needle] Searches for the string
		 * needle in the string haystack Requires: KMPTableGen(String)
		 */
		public boolean KMPSearch(String needle, String haystack) {
			int m = 0;
			int i = 0;
			int[] T = KMPTableGen(needle);
			while (m + i < haystack.length()) {
				if (needle.charAt(i) == haystack.charAt(m + i)) {
//					if (i == needle.length() - 1)
//						return m;
					i++;
				} else {
					m = m + i - T[i];
					if (T[i] > -1)
						i = T[i];
					else
						i = 0;
				}
			}
			//return haystack.length();
			return  i ==0;
		}
	}

}


import java.util.Scanner;
public class tr {
    public static void main (String args []){
        Scanner s = new Scanner(System.in);
        int sum = 0;int x ;
        for(int i = 0 ; i < 5;++i){
            x=s.nextInt();
            sum+=x;
        }

        if(sum%5==0&&sum!=0){
            System.out.println(sum/5);
        }
        else{
            System.out.println(-1);
        }

    }}