import java.util.*;

/**
 * Created by IntelliJ IDEA.
 * User: piyushd
 * Date: 3/29/11
 * Time: 7:56 PM
 * To change this template use File | Settings | File Templates.
 */
public class TaskD {

    void run() {
        int[][][] have = new int[2][10][10];
        for(char x : next().toCharArray()) {
            for(int i = 0; i < 10; i++) {
                have[0][i][x - '0']++;
                have[1][i][x - '0']++;
            }
        }

        String x1 = "", x2 = "";
        int maxMatch = -1;
        for(int firstMatch = 0; firstMatch < 10; firstMatch++) {
            String xx1 = "", xx2 = "";
            int[] cnt1 = have[0][firstMatch];
            int[] cnt2 = have[1][firstMatch];
            int match = 0, carry = 0;

            if(firstMatch == 0) {
                int need = 0;
                if(cnt1[firstMatch] > 0 && cnt2[need] > 0) {
                    xx1 = (char) (firstMatch + '0') + xx1;
                    xx2 = (char) (need + '0') + xx2;
                    cnt1[firstMatch]--;
                    cnt2[need]--;
                    match++;
                }
            }
            else {
                int need = 10 - firstMatch;
                if(cnt1[firstMatch] > 0 && cnt2[need] > 0) {
                    xx1 = (char) (firstMatch + '0') + xx1;
                    xx2 = (char) (need + '0') + xx2;
                    cnt1[firstMatch]--;
                    cnt2[need]--;
                    carry = 1;
                    match++;
                }
            }

            for(int iter = 0; iter < 2; iter++) {
                int cur = 0;
                while(cur < 10) {
                    if(cnt1[cur] > 0) {
                        if(cur == 0) {
                            int need = (carry > 0) ? 9 : 0;
                            if(cnt2[need] > 0) {
                                xx1 = (char) (cur + '0') + xx1;
                                xx2 = (char) (need + '0') + xx2;
                                cnt1[cur]--;
                                cnt2[need]--;
                                match++;
                            }
                            else {
                                cur++;
                            }
                        }
                        else {
                            int need = 10 - cur - carry;
                            if(cnt2[need] > 0) {
                                xx1 = (char) (cur + '0') + xx1;
                                xx2 = (char) (need + '0') + xx2;
                                cnt1[cur]--;
                                cnt2[need]--;
                                match++;
                                carry = 1;
                            }
                            else {
                                cur++;
                            }
                        }
                    }
                    else {
                        cur++;
                    }
                }
            }

            StringBuilder builder = new StringBuilder();
            while (cnt1[0] > 0 && cnt2[0] > 0) {
                builder.append("0");
                cnt1[0]--;
                cnt2[0]--;
                match++;
            }
            xx1 = xx1.concat(builder.toString());
            xx2 = xx2.concat(builder.toString());

            if(match > maxMatch) {
                maxMatch = match;
                StringBuilder builder1 = new StringBuilder();
                StringBuilder builder2 = new StringBuilder();
                for(int i = 0; i < 10; i++) {
                    for(int j = 0; j < cnt1[i]; j++) builder1.append((char)(i + '0'));
                    for(int j = 0; j < cnt2[i]; j++) builder2.append((char)(i + '0'));
                }

                x1 = builder1.toString() + xx1;
                x2 = builder2.toString() + xx2;
            }
        }

        System.out.println(x1);
        System.out.println(x2);
    }

    int nextInt(){
        try{
            int c = System.in.read();
            if(c == -1) return c;
            while(c != '-' && (c < '0' || '9' < c)){
                c = System.in.read();
                if(c == -1) return c;
            }
            if(c == '-') return -nextInt();
            int res = 0;
            do{
                res *= 10;
                res += c - '0';
                c = System.in.read();
            }while('0' <= c && c <= '9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

    long nextLong(){
        try{
            int c = System.in.read();
            if(c == -1) return -1;
            while(c != '-' && (c < '0' || '9' < c)){
                c = System.in.read();
                if(c == -1) return -1;
            }
            if(c == '-') return -nextLong();
            long res = 0;
            do{
                res *= 10;
                res += c-'0';
                c = System.in.read();
            }while('0' <= c && c <= '9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

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

    String next(){
        try{
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while(Character.isWhitespace(c))
                c = System.in.read();
            do{
                res.append((char)c);
            }while(!Character.isWhitespace(c=System.in.read()));
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }

    String nextLine(){
        try{
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while(c == '\r' || c == '\n')
                c = System.in.read();
            do{
                res.append((char)c);
                c = System.in.read();
            }while(c != '\r' && c != '\n');
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }

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


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Collection;
import java.io.IOException;
import java.util.Deque;
import java.util.ArrayDeque;
import java.io.InputStream;

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

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

    static class CJoker {
        Debug debug = new Debug(true);

        public void solve(int testNumber, FastInput in, PrintWriter out) {
            int n = in.readInt();
            int m = in.readInt();
            int q = in.readInt();

            int[][] edges = new int[2][m + 1];
            for (int i = 1; i <= m; i++) {
                for (int j = 0; j < 2; j++) {
                    edges[j][i] = in.readInt() - 1;
                }
            }
            OperationQueue oq = new OperationQueue(m);
            XorDSU dsu = new XorDSU(n);
            int cur = 1;
            for (int i = 1; i <= m; i++) {
                int a = edges[0][i];
                int b = edges[1][i];
                while (dsu.find(a) == dsu.find(b) && dsu.delta(a, b) == 0) {
                    oq.remove();
                    cur++;
                }
                dsu.merge(a, b, oq);
            }

            int[] right = new int[m + 1];
            right[0] = cur;
            for (int i = 1; i <= m; i++) {
                int a = edges[0][i];
                int b = edges[1][i];
                while (cur <= i) {
                    cur++;
                    oq.remove();
                }
                while (cur <= m && dsu.find(a) == dsu.find(b) && dsu.delta(a, b) == 0) {
                    oq.remove();
                    cur++;
                }
                if (cur == m + 1 && dsu.find(a) == dsu.find(b) && dsu.delta(a, b) == 0) {
                    cur++;
                }
                dsu.merge(a, b, oq);
                right[i] = cur;
            }

            for (int i = 0; i < q; i++) {
                int l = in.readInt();
                int r = in.readInt();
                if (right[l - 1] - 1 > r) {
                    out.println("YES");
                } else {
                    out.println("NO");
                }
            }

            debug.debug("right", right);
        }

    }

    static class XorDSU {
        int[] p;
        int[] rank;
        int[] xor;

        public XorDSU(int n) {
            p = new int[n];
            rank = new int[n];
            xor = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = -1;
                rank[i] = 1;
            }
        }

        public int find(int x) {
            return p[x] == -1 ? x : find(p[x]);
        }

        public int delta(int a, int b) {
            return deltaToRoot(a) ^ deltaToRoot(b);
        }

        public int deltaToRoot(int a) {
            int ans = 0;
            while (p[a] != -1) {
                ans ^= xor[a];
                a = p[a];
            }
            return ans;
        }

        public void merge(int a, int b, OperationQueue queue) {
            queue.add(new OperationQueue.CommutativeOperation() {
                int x;
                int y;

                public void apply() {
                    x = find(a);
                    y = find(b);
                    if (x == y) {
                        return;
                    }
                    if (rank[x] < rank[y]) {
                        int tmp = x;
                        x = y;
                        y = tmp;
                    }
                    xor[y] = deltaToRoot(a) ^ deltaToRoot(b) ^ 1;
                    p[y] = x;
                    rank[x] += rank[y];
                }

                public void undo() {
                    if (x == y) {
                        return;
                    }
                    int cur = y;
                    while (p[cur] != -1) {
                        cur = p[cur];
                        rank[cur] -= rank[y];
                    }
                    p[y] = -1;
                }
            });
        }

    }

    static interface Operation {
        void apply();

        void undo();

    }

    static class OperationQueue {
        private Deque<OperationQueue.CommutativeOperation> dq;
        private Deque<OperationQueue.CommutativeOperation> bufA;
        private Deque<OperationQueue.CommutativeOperation> bufB;

        public OperationQueue(int size) {
            dq = new ArrayDeque<>(size);
            bufA = new ArrayDeque<>(size);
            bufB = new ArrayDeque<>(size);
        }

        public void add(OperationQueue.CommutativeOperation op) {
            pushAndDo(op);
        }

        private void pushAndDo(OperationQueue.CommutativeOperation op) {
            dq.addLast(op);
            op.apply();
        }

        private void popAndUndo() {
            OperationQueue.CommutativeOperation ans = dq.removeLast();
            ans.undo();
            if (ans.a) {
                bufA.addLast(ans);
            } else {
                bufB.addLast(ans);
            }
        }

        public void remove() {
            if (!dq.peekLast().a) {
                popAndUndo();
                while (!dq.isEmpty() && bufB.size() != bufA.size()) {
                    popAndUndo();
                }
                if (dq.isEmpty()) {
                    while (!bufB.isEmpty()) {
                        OperationQueue.CommutativeOperation ans = bufB.removeFirst();
                        ans.a = true;
                        pushAndDo(ans);
                    }
                } else {
                    while (!bufB.isEmpty()) {
                        OperationQueue.CommutativeOperation ans = bufB.removeLast();
                        pushAndDo(ans);
                    }
                }
                while (!bufA.isEmpty()) {
                    pushAndDo(bufA.removeLast());
                }
            }

            dq.removeLast().undo();
        }

        public static abstract class CommutativeOperation implements Operation {
            private boolean a;

        }

    }

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

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

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

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

        public int readInt() {
            int sign = 1;

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

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

            return val;
        }

    }

    static class Debug {
        private boolean offline;
        private PrintStream out = System.err;
        static int[] empty = new int[0];

        public Debug(boolean enable) {
            offline = enable && System.getSecurityManager() == null;
        }

        public Debug debug(String name, Object x) {
            return debug(name, x, empty);
        }

        public Debug debug(String name, Object x, int... indexes) {
            if (offline) {
                if (x == null || !x.getClass().isArray()) {
                    out.append(name);
                    for (int i : indexes) {
                        out.printf("[%d]", i);
                    }
                    out.append("=").append("" + x);
                    out.println();
                } else {
                    indexes = Arrays.copyOf(indexes, indexes.length + 1);
                    if (x instanceof byte[]) {
                        byte[] arr = (byte[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof short[]) {
                        short[] arr = (short[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof boolean[]) {
                        boolean[] arr = (boolean[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof char[]) {
                        char[] arr = (char[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof int[]) {
                        int[] arr = (int[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof float[]) {
                        float[] arr = (float[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof double[]) {
                        double[] arr = (double[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else if (x instanceof long[]) {
                        long[] arr = (long[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    } else {
                        Object[] arr = (Object[]) x;
                        for (int i = 0; i < arr.length; i++) {
                            indexes[indexes.length - 1] = i;
                            debug(name, arr[i], indexes);
                        }
                    }
                }
            }
            return this;
        }

    }
}


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

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

    static class TaskA {
        static int[] p = new int[250];
        static int[] d = new int[100];
        static int n;
        static int l;
        static int k;
        static int dist;

        static boolean dfs(int time, boolean[][] vis) {
            dist++;
            if (dist == n + 1) return true;
            for (int i = time + 1; i < 2 * k + time + 1; i++) {
                if (vis[dist][i % (2 * k)]) continue;
                vis[dist][i % (2 * k)] = true;
                if (d[dist] + p[i % (2 * k)] <= l) {
                    if (dfs(i, vis)) return true;
                } else break;
            }
            dist--;
            return false;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int t = in.nextInt();
            while (t-- > 0) {
                n = in.nextInt();
                k = in.nextInt();
                l = in.nextInt();
                for (int i = 1; i <= n; i++)
                    d[i] = in.nextInt();
                for (int i = 0; i < 2 * k; i++) {
                    if (i < k) p[i] = i;
                    else p[i] = 2 * k - i;
                }
                boolean[][] vis = new boolean[110][110];
                for (int i = 0; i < 2 * k; i++) {
                    dist = 1;
                    if (d[dist] + p[i] <= l) {
                        if (dfs(i, vis)) {
                            out.println("Yes");
                            break;
                        }
                    }
                    if (i == 2 * k - 1) out.println("No");
                }
            }
        }

    }
}


//import com.sun.org.apache.xpath.internal.operations.String;

//import com.sun.org.apache.xpath.internal.operations.String;

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;

public class scratch_25 {
    // int count=0;
    //static long count=0;
    static class Reader {
        static BufferedReader reader;
        static StringTokenizer tokenizer;

        /**
         * call this method to initialize reader for InputStream
         */
        static void init(InputStream input) {
            reader = new BufferedReader(
                    new InputStreamReader(input));
            tokenizer = new StringTokenizer("");
        }

        /**
         * get next word
         */
        static String next() throws IOException {
            while (!tokenizer.hasMoreTokens()) {
                //TODO add check for eof if necessary
                tokenizer = new StringTokenizer(
                        reader.readLine());
            }
            return tokenizer.nextToken();
        }

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

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

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

    public static class Graph{
        public static class Vertex{
            HashMap<Integer,Integer> nb= new HashMap<>();     // for neighbours of each vertex
        }

        public static HashMap<Integer,Vertex> vt;   // for vertices(all)

        public Graph(){
            vt= new HashMap<>();
        }

        public static int numVer(){
            return vt.size();
        }

        public static boolean contVer(int ver){
            return vt.containsKey(ver);
        }

        public static void addVer(int ver){
            Vertex v= new Vertex();
            vt.put(ver,v);
        }

        public static int numEdg(){
            int count=0;
            ArrayList<Integer> vrtc= new ArrayList<>(vt.keySet());
            for (int i = 0; i <vrtc.size() ; i++) {
                count+=(vt.get(vrtc.get(i))).nb.size();
            }
            return count/2;
        }

        public static boolean contEdg(int ver1, int ver2){
            if(vt.get(ver1)==null || vt.get(ver2)==null){
                return false;
            }

            Vertex v= vt.get(ver1);
            if(v.nb.containsKey(ver2)){
                return true;
            }
            return false;
        }

        public static void addEdge(int ver1, int ver2, int weight){
            if(!vt.containsKey(ver1) || !vt.containsKey(ver2)){
                return;
            }
            Vertex v1= vt.get(ver1);
            Vertex v2= vt.get(ver2);
            v1.nb.put(ver2,weight);                                 // if previously there is an edge, then this replaces that edge
            v2.nb.put(ver1,weight);
        }

        public static void delEdge(int ver1, int ver2){

            if(!vt.containsKey(ver1) || !vt.containsKey(ver2)){
                return;
            }

            vt.get(ver1).nb.remove(ver2);
            vt.get(ver2).nb.remove(ver1);

        }

        public static void delVer(int ver){
            if(!vt.containsKey(ver)){
                return;
            }
            Vertex v1= vt.get(ver);
            ArrayList<Integer> arr= new ArrayList<>(v1.nb.keySet());
            for (int i = 0; i <arr.size() ; i++) {
                int s= arr.get(i);
                vt.get(s).nb.remove(ver);
            }
            vt.remove(ver);
        }

        public class Pair{
            int vname;
            ArrayList<Integer> psf= new ArrayList<>();       // path so far
            int dis;
            int col;
        }

        public HashMap<Integer,Integer> bfs(int src){
            HashMap<Integer, Boolean> prcd= new HashMap<>();    // jo jo ho chuke hain unke liye

            HashMap<Integer, Integer> ans= new HashMap<>();

            LinkedList<Pair> queue= new LinkedList<>();      // for bfs queue

            Pair strtp= new Pair();

            strtp.vname= src;

            ArrayList<Integer> ar= new ArrayList<>();
            ar.add(src);

            strtp.psf= ar;
            strtp.dis=0;

            queue.addLast(strtp);

            while(!queue.isEmpty()){

                Pair rp =  queue.removeFirst();

                if(prcd.containsKey(rp.vname)){
                    continue;
                }
                prcd.put(rp.vname,true);
                ans.put(rp.vname,rp.dis);

//                if(contEdg(rp.vname,dst)){
//                    return true;
//                }

                Vertex a= vt.get(rp.vname);
                ArrayList<Integer> arr= new ArrayList<>(a.nb.keySet());
                for (int i = 0; i <arr.size() ; i++) {
                    int s= arr.get(i);
                    if(!prcd.containsKey(s)){
                        Pair np = new Pair();
                        np.vname= s;
                        np.dis+=rp.dis+a.nb.get(s);
                        np.psf.addAll(rp.psf);
                        np.psf.add(s);
//                        np.psf.add(s);
//                         np.psf= rp.psf+" "+s;
                        queue.addLast(np);
                    }

                }
            }
            return ans;

            //   return false;
        }

        public HashMap<Integer,Integer> dfs(int src){
            HashMap<Integer, Boolean> prcd= new HashMap<>();    // jo jo ho chuke hain unke liye

            HashMap<Integer, Integer> ans= new HashMap<>();

            LinkedList<Pair> stack= new LinkedList<>();      // for bfs queue

            Pair strtp= new Pair();

            strtp.vname= src;

            ArrayList<Integer> ar= new ArrayList<>();
            ar.add(src);

            strtp.psf= ar;
            strtp.dis=0;

            stack.addFirst(strtp);

            while(!stack.isEmpty()){

                Pair rp =  stack.removeFirst();

                if(prcd.containsKey(rp.vname)){
                    continue;
                }
                prcd.put(rp.vname,true);
                ans.put(rp.vname,rp.dis);

//                if(contEdg(rp.vname,dst)){
//                    return true;
//                }

                Vertex a= vt.get(rp.vname);
                ArrayList<Integer> arr= new ArrayList<>(a.nb.keySet());
                for (int i = 0; i <arr.size() ; i++) {
                    int s= arr.get(i);
                    if(!prcd.containsKey(s)){
                        Pair np = new Pair();
                        np.vname= s;
                        np.dis+=rp.dis+a.nb.get(s);
                        np.psf.addAll(rp.psf);
                        np.psf.add(s);
//                        np.psf.add(s);
//                         np.psf= rp.psf+" "+s;
                        stack.addFirst(np);
                    }

                }
            }
            return ans;

            //   return false;
        }

        public boolean isCycle(){
            HashMap<Integer, Boolean> prcd= new HashMap<>();    // jo jo ho chuke hain unke liye

            //   HashMap<Integer, Integer> ans= new HashMap<>();

            LinkedList<Pair> queue= new LinkedList<>();      // for bfs queue

            ArrayList<Integer> keys = new ArrayList<>(vt.keySet());
            for (int i = 0; i <keys.size(); i++) {
                int cur= keys.get(i);
                if(prcd.containsKey(cur)){
                    continue;
                }

                Pair sp = new Pair();
                sp.vname= cur;
                ArrayList<Integer> as= new ArrayList<>();
                as.add(cur);
                sp.psf= as;

                queue.addLast(sp);

                while(!queue.isEmpty()){

                    Pair rp= queue.removeFirst();
                    if(prcd.containsKey(rp.vname)){
                        return true;
                    }

                    prcd.put(rp.vname,true);

                    Vertex v1= vt.get(rp.vname);
                    ArrayList<Integer> nbrs= new ArrayList<>(v1.nb.keySet());
                    for (int j = 0; j <nbrs.size() ; j++) {
                        int u= nbrs.get(j);
                        Pair np= new Pair();
                        np.vname= u;
                        queue.addLast(np);
                    }
                }

            }
            return false;
        }

        public  ArrayList<ArrayList<Integer>> genConnctdComp(){
            HashMap<Integer, Boolean> prcd= new HashMap<>();    // jo jo ho chuke hain unke liye

            ArrayList<ArrayList<Integer>> ans= new ArrayList<>();

            //   HashMap<Integer, Integer> ans= new HashMap<>();

            LinkedList<Pair> queue= new LinkedList<>();      // for bfs queue

            //  int con=-1;

            ArrayList<Integer> keys = new ArrayList<>(vt.keySet());
            for (int i = 0; i <keys.size(); i++) {
                int cur= keys.get(i);
                if(prcd.containsKey(cur)){
                    //return true;
                    continue;
                }
                int count=0;
                ArrayList<Integer> fu= new ArrayList<>();
                fu.add(cur);

                Pair sp = new Pair();
                sp.vname= cur;
                ArrayList<Integer> as= new ArrayList<>();
                as.add(cur);
                sp.psf= as;

                queue.addLast(sp);

                while(!queue.isEmpty()){

                    Pair rp= queue.removeFirst();
                    if(prcd.containsKey(rp.vname)){
                        //return true;
                        continue;
                    }

                    prcd.put(rp.vname,true);
                    fu.add(rp.vname);

                    Vertex v1= vt.get(rp.vname);
                    ArrayList<Integer> nbrs= new ArrayList<>(v1.nb.keySet());
                    for (int j = 0; j <nbrs.size() ; j++) {
                        int u= nbrs.get(j);
                        if(!prcd.containsKey(u)){
                            count++;
                            Pair np= new Pair();
                            np.vname= u;
                            queue.addLast(np);
                        }
                    }}
                fu.add(count);
                ans.add(fu);

            }
            //return false;
            return ans;

        }

        public boolean isBip(int src){                       // only for connected graph

            HashMap<Integer,Integer> clr= new HashMap<>();
            // colors are 1 and -1

            LinkedList<Integer>q = new LinkedList<Integer>();
            clr.put(src,1);
            q.add(src);

            while(!q.isEmpty()){

                int u = q.getFirst();
                q.pop();

                ArrayList<Integer> arr= new ArrayList<>(vt.keySet());

                for (int i = 0; i <arr.size() ; ++i) {

                    int x= arr.get(i);

                    if(vt.get(u).nb.containsKey(x) && !clr.containsKey(x)){

                        if(clr.get(u)==1){
                            clr.put(x,-1);
                        }
                        else{
                            clr.put(x,1);
                        }
                        q.push(x);
                    }

                    else if(vt.get(u).nb.containsKey(x) && (clr.get(x)==clr.get(u))){
                        return false;
                    }

                }
            }
            return true;
        }

        public static void printGr() {
            ArrayList<Integer> arr= new ArrayList<>(vt.keySet());
            for (int i = 0; i <arr.size() ; i++) {
                int ver= arr.get(i);
                Vertex v1= vt.get(ver);
                ArrayList<Integer> arr1= new ArrayList<>(v1.nb.keySet());
                for (int j = 0; j <arr1.size() ; j++) {
                    System.out.println(ver+"-"+arr1.get(j)+":"+v1.nb.get(arr1.get(j)));
                }

            }
        }
    }

    static class Cus implements Comparable<Cus>{
        int size;
        int mon;
        int num;
        public Cus(int size,int mon,int num){
            this.size=size;
            this.mon=mon;
            this.num=num;
        }
        @Override
        public int compareTo(Cus o){
            if(this.mon!=o.mon){
                return this.mon-o.mon;}

            else{
                return o.size-this.size;
            }

        }

    }

    static class Table implements Comparable<Table>{
        int go;
      //  int cum;
        int cost;
        public Table(int go,int cost){
            this.go=go;
        //    this.cum=cum;
            this.cost=cost;
        }
        @Override
        public int compareTo(Table o){

            return this.cost-o.cost;

        }

    }
    static class Table1 implements Comparable<Table1>{
        int go;
        //int cum;
        int cost;
        public Table1(int go,int cost){
            this.go=go;
          //  this.cum=cum;
            this.cost=cost;
        }
        @Override
        public int compareTo(Table1 o){
            return this.cost-o.cost;

        }}

    public static class DisjointSet{
        HashMap<Integer,Node> mp= new HashMap<>();

        public static class Node{
            int data;
            Node parent;
            int rank;
        }

        public void create(int val){
            Node nn= new Node();
            nn.data=val;
            nn.parent=nn;
            nn.rank=0;
            mp.put(val,nn);
        }

        public int find(int val){

            return findn(mp.get(val)).data;

        }

        public Node findn(Node n){
            if(n==n.parent){
                return n;
            }
            Node rr= findn(n.parent);
            n.parent=rr;
            return rr;
        }

        public void union(int val1, int val2){                                                                               // can also be used to check cycles

            Node n1= findn(mp.get(val1));
            Node n2= findn(mp.get(val2));

            if(n1.data==n2.data) {
                return;
            }

            if(n1.rank<n2.rank){
                n1.parent=n2;
            }

            else if(n2.rank<n1.rank){
                n2.parent=n1;
            }

            else {
                n2.parent=n1;
                n1.rank++;
            }

        }
    }

    public static void main(String[] args)  throws IOException {
        Reader.init(System.in);
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        ArrayList<Integer>ar= Sieve(100000000);
       long p= Reader.nextLong();
       long q= Reader.nextLong();
       double f= (1.0*p)/(1.0*q);
       double arr[]= new double[2000000+1];
       long n=0;
       long d=0;
       int ans=0;
        for (int i = 1; i <2000000 ; i++) {
         //   System.out.println("d="+d);
            if(Collections.binarySearch(ar,i)>=0){
                n++;
            }
            StringBuilder s= new StringBuilder(String.valueOf(i));
            if(s.toString().equals((s.reverse()).toString())){
                d++;
            }
            if((1.0*n)/(1.0*d)<=f){
                ans=i;
                //System.out.println(i-1);
                //break;
            }

        }
        System.out.println(ans);

    }
    public static long ceil_div(long a, long b){
        return (a+b-1)/b;
    }

    static int countDivisibles(int A, int B, int M)
    {
        // Add 1 explicitly as A is divisible by M
        if (A % M == 0)
            return (B / M) - (A / M) + 1;

        // A is not divisible by M
        return (B / M) - (A / M);
    }

    public static void df(int x, int y,int n, int m, char[][]ar, int l){
        boolean done[][]= new boolean[n][m];
        int count=0;
        LinkedList<int[]> stk= new LinkedList<>();
        int a[]= {x,y};
        stk.addFirst(a);
        while(!stk.isEmpty() && count<l){
            //  count++;
            int b[]=stk.removeFirst();
            if( done[b[0]][b[1]]){
                continue;
            }
            count++;

            done[b[0]][b[1]]=true;
            ar[b[0]][b[1]]='@';
            int arr[][]={{1,0},{-1,0},{0,1},{0,-1}};
            for (int i = 0; i <arr.length ; i++) {
                if(!(b[0]+arr[i][0]>=n || b[1]+arr[i][1]>=m || b[0]+arr[i][0]<0 || b[1]+arr[i][1]<0 ||  ar[b[0]+arr[i][0]][b[1]+arr[i][1]]=='#')){
                    int r[]= {b[0]+arr[i][0], b[1]+arr[i][1]};
                    stk.addFirst(r);
                    // continue;

                }
            }}

        for (int i = 0; i <n ; i++) {
            for (int j = 0; j <m ; j++) {
                if(ar[i][j]=='.'){
                    System.out.print('X');
                }
                else if(ar[i][j]=='@'){
                    System.out.print('.');
                }
                else{
                    System.out.print(ar[i][j]);
                }
            }
            System.out.println();
        }

    }

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

    static long gcd1(long a, long b)
    {

        // Everything divides 0
        if (a == 0)
            return b;
        if (b == 0)
            return a;

        // base case
        if (a == b)
            return a;

        // a is greater
        //count++;
        if (a > b){
            return gcd(a-b, b);

        }
        return gcd(a, b-a);
    }

    // method to return LCM of two numbers
    static long lcm(long a, long b)
    {
        return (a*b)/gcd(a, b);
    }

    // Driver method

    static int partition(long arr[],long arr1[], int low, int high)
    {
        long pivot = arr[high];
        int i = (low-1); // index of smaller element
        for (int j=low; j<high; j++)
        {
            // If current element is smaller than the pivot
            if (arr[j] < pivot)
            {
                i++;

                // swap arr[i] and arr[j]
                long temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
                long temp1=arr1[i];
                arr1[i]=arr1[j];
                arr1[j]=temp1;

            }
        }

        // swap arr[i+1] and arr[high] (or pivot)
        long temp = arr[i+1];
        arr[i+1] = arr[high];
        arr[high] = temp;
        long temp1= arr1[i+1];
        arr1[i+1]=arr1[high];
        arr1[high]= temp1;

        return i+1;
    }

    /* The main function that implements QuickSort()
      arr[] --> Array to be sorted,
      low  --> Starting index,
      high  --> Ending index */
    static void sort(long arr[],long arr1[], int low, int high)
    {
        if (low < high)
        {
            /* pi is partitioning index, arr[pi] is
              now at right place */
            int pi = partition(arr,arr1, low, high);

            // Recursively sort elements before
            // partition and after partition
            sort(arr,arr1, low, pi-1);
            sort(arr,arr1, pi+1, high);
        }
    }

    public static ArrayList<Integer> Sieve(int n) {
        boolean arr[]= new boolean [n+1];
        Arrays.fill(arr,true);
        arr[0]=false;
        arr[1]=false;
        for (int i = 2; i*i <=n ; i++) {
            if(arr[i]){
                for (int j = 2; j <=n/i ; j++) {
                    int u= i*j;
                    arr[u]=false;
                }}
        }
        ArrayList<Integer> ans= new ArrayList<>();
        for (int i = 0; i <n+1 ; i++) {
            if(arr[i]){
                ans.add(i);
            }
        }
        return ans;

    }

}


import java.util.*;
public class math {
    public static void main(String args[]);
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    System.out.println((n * n)- (2 * n)));
}


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

public class MadokaAndTheBestUniversity {
	private static final int N_MAX = 100_000;

	private static final int MOD = 1_000_000_007;

	private static final IntList[] FACTORS = new IntList[N_MAX + 1];
	static {
		for (int i = 1; i <= N_MAX; ++i) {
			FACTORS[i] = new IntList();
		}
		for (int i = 1; i <= N_MAX; ++i) {
			for (int j = i; j <= N_MAX; j += i) {
				FACTORS[j].add(i);
			}
		}
	}

	public static void solve(FastIO io) {
		final int N = io.nextInt();

		long total = 0;
		for (int c = 1; c + 2 <= N; ++c) {
			int rem = N - c;
			System.out.format("c = %d, rem = %d\n", c, rem);
			IntList facs = FACTORS[rem];
			int[] countFacs = new int[facs.size()];
			for (int i = facs.size() - 1; i >= 0; --i) {
				int fi = facs.get(i);
				countFacs[i] = rem / fi - 1;
				for (int j = i + 1; j < facs.size(); ++j) {
					int fj = facs.get(j);
					if (fj % fi != 0) {
						continue;
					}
					countFacs[i] -= countFacs[j];
				}
				total += 1L * c * facs.get(i) * countFacs[i] / gcd(fi, c);
				total %= MOD;
			}
		}
		io.println(total);
	}

	/**
	 * Computes the GCD (greatest common denominator) between two numbers.
	 */
	public static int gcd(int a, int b) {
		if (a < b)
			return gcd(b, a);

		int r = a % b;
		if (r == 0)
			return b;

		return gcd(b, r);
	}

	private static class IntList extends ArrayList<Integer> {
		private static final long serialVersionUID = 8986468115134862220L;
	}

	public static class FastIO {
		private InputStream reader;
		private PrintWriter writer;

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

		public FastIO(InputStream r, OutputStream w) {
			reader = r;
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(w)));
		}

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

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

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

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

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

		// TODO: read this byte-by-byte like the other read functions.
		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			return nextIntArray(n, 0);
		}

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

		public long[] nextLongArray(int n) {
			return nextLongArray(n, 0);
		}

		public long[] nextLongArray(int n, int off) {
			long[] arr = new long[n + off];
			for (int i = 0; i < n; i++) {
				arr[i + off] = nextLong();
			}
			return arr;
		}

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

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

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

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

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

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

		public void printlnArray(int[] arr) {
			printArray(arr);
			writer.println();
		}

		public void printlnArray(long[] arr) {
			printArray(arr);
			writer.println();
		}

		public void printf(String format, Object... args) {
			print(String.format(format, args));
		}

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

	public static void main(String[] args) {
		FastIO io = new FastIO(System.in, System.out);
		solve(io);
		io.flush();
	}
}


import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * User: Sabyrzhan_Tynybayev
 * Date: 7/15/13
 * Time: 6:41 PM
 * To change this template use File | Settings | File Templates.
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        String numbers = sc.nextLine();
        String av = sc.nextLine();
        int totalCount = 0;
        while(true) {
            int count = 0;
            List<String> items = new ArrayList<>();
            for(int i = 0; i < av.length(); i++) {
                items.add(String.valueOf(av.charAt(i)));
            }

            for(int i = 0; i < numbers.length(); i++) {
                boolean isItemUsed = false;
                for(int j = 0; j < items.size(); j++) {
                    if((items.get(j).equals(String.valueOf(numbers.charAt(i))) || isItems2or5(String.valueOf(numbers.charAt(i)), items.get(j)) || isItems6or9(String.valueOf(numbers.charAt(i)), items.get(j))) && !isItemUsed) {
                        items.set(j, "");
                        count++;
                        isItemUsed = true;
                    }
                }
            }

            if(count != numbers.length()) {
                break;
            }

            totalCount++;
            av = "";
            for(int i = 0; i < items.size(); i++) {
                if(items.get(i) != null) {
                    av += items.get(i);
                }
            }
        }

        pw.println(totalCount);
        pw.close();
        sc.close();
    }

    static boolean isItems2or5(String number, String listItem) {
        return ("2".equals(number) && "5".equals(listItem)) || ("5".equals(number) && "2".equals(listItem));
    }

    static boolean isItems6or9(String number, String listItem) {
        return ("6".equals(number) && "9".equals(listItem)) || ("9".equals(number) && "6".equals(listItem));
    }
}


//package com.company;
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        long n = scn.nextInt();
        long p = scn.nextInt();
        scn.nextLine();
        long res = p/2, apples = 1;
        String s = new String();
        String[] mas = new String[n];

        for (int i=0; i<n;i++){
            mas[i] = scn.nextLine(); //считывем строки в массив
        }

        for (int i = n-2; i>=0;i--){
            if (mas[i].equals("half")){
                res += p*apples;
                apples*=2;
            }
            else {
                res += p*apples+p/2;
                apples*=2;
                apples++;
            }
        }
        System.out.println(res);

    }
}


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

public class D {
	Scanner in;
	PrintWriter out;
	String INPUT = "7 8 15";
	int mod = 1000000007;

	// 1列の場合はなんでもありなのでk^n
	// 2列の場合はどっちも同じi色であればいいので、
	// \sum_i (C(k,i)F(n,i))^2
	// 3列以上の場合は両端が共通部分を1色以上持つ同じ色数の配色、真ん中はその色内ならなんでもよい。
	// |A|<=|A\cup C|=|B|, |B|<=|B\cup C|=|A|
	// |A|=|B|, C\in A\cup B
	// \sum_i (F(n,i)^2)\sum_p=1^i C(k,p)p^{n(m-2)}C(k-p,i-p)C(k-i,i-p)
	// C(k,p)C(k-p,i-p)C(k-i,i-p)
	// =k!/p!(i-p)!(k-2i+p)!(i-p)!
	// F(n,i)はn行をちょうどi色で塗る塗り方
	// F(n,i)=i^n-C(i,1)(i-1)^n+C(i,2)(i-2)^n-...
	// これを求めるのにO(i)
	// 全体でO(k^2)かかってしまうので普通の計算では間に合わない。
	//
	//

	void solve()
	{
		int n = ni();
		int m = ni();
		int K = ni();

		long[] A = new long[K+1];
		long[] IA = new long[K+1];
		A[0] = 1;
		IA[0] = 1;
		for(int i = 1;i <= K;i++){
			A[i] = A[i-1] * i % mod;
			IA[i] = inv(A[i], mod);
		}

		long[] I = new long[1001];
		long[] IM = new long[1001];
		for(int i = 0;i <= 1000;i++){
			I[i] = modpow(i, n, mod);
			IM[i] = modpow(i, n*(m-2), mod);
		}

		// F(n,i)=i^n-C(i,1)(i-1)^n+C(i,2)(i-2)^n-...
		long[] F = new long[n+1];
		for(int i = 0;i <= n;i++){
			long val = 0;
			long minus = 1;
			for(int j = i;j >= 0;j--){
				val += I[j] * minus * A[i]%mod*IA[i-j]%mod*IA[j] % mod;
				minus = -minus;
			}
			F[i] = (val%mod+mod)%mod;
		}

		if(m == 1){
			out.println(modpow(K, n, mod));
		}else if(m == 2){
			long sum = 0;
			for(int i = 1;i <= K;i++){
				long cfm = A[K]%mod*IA[i]%mod*IA[K-i]%mod*F[i]%mod;
				sum += cfm*cfm%mod;
			}
			out.println(sum%mod);
		}else{
			long sum = 0;
			// \sum_i (F(n,i)^2)\sum_p=1^i C(k,p)p^{n(m-2)}C(k-p,i-p)C(k-i,i-p)
			// =k!/p!(i-p)!(k-2i+p)!(i-p)!
			for(int i = 1;i <= Math.min(K, n);i++){
				long psum = 0;
				for(int p = 1;p <= i;p++){
					psum += A[K]*IA[p]%mod*IA[i-p]%mod*IA[i-p]%mod*IA[K-2*i+p]%mod*IM[p]%mod;
				}
				psum%=mod;
				long all = F[i]*F[i]%mod*psum%mod;
				sum += all;
			}
			out.println(sum%mod);
		}
	}

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

	public static long modpow(long a, long n, long mod)
	{
		long ret = 1;
		long mul = a;
		for(;n > 0;n >>>= 1){
			if((n&1)==1){
				ret = (ret * mul) % mod;
			}
			mul = (mul * mul) % mod;
		}
		return ret;
	}

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

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

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

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


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Village {
    public static void main(String[] args) throws IOException {
    	InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        // InputStream inputStream = new FileInputStream("input.txt");
        // OutputStream outputStream = new FileOutputStream("output.txt");

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskA {
        long mod = (long)(998244353);
        long fact[];
        int depth[];
        int parentTable[][];
        int degree[];
        ArrayList<Integer> leaves;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;

    	int ans = 0;

        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            while(testNumber-->0){
            	int n = in.nextInt();
            	ArrayList<ArrayList<Integer>> a = new ArrayList<>();
            	for(int i=0;i<=n;i++)
            		a.add(new ArrayList<>());
            	for(int i=0;i<n-1;i++){
            		int u = in.nextInt();
            		int v = in.nextInt();
            		a.get(u).add(v);
            		a.get(v).add(u);
            	}
            	// out.println(a);
            	int b[] = new int[n+1];
            	for(int i=0;i<=n;i++)
            		b[i] = i;
            	dfs(a , 0 , 1 , b);
            	out.println(ans);
            	for(int i=1;i<=n;i++)
            		out.print(b[i] + " ");
            	out.println();
            }
        }

        public void dfs(ArrayList<ArrayList<Integer>> a , int parent , int index , int b[]){
        	// visited[u] = 1;
        	for(int i=0;i<a.get(index).size();i++){
        		int u = index;
        		int v = a.get(index).get(i);
        		if(b[v] != v || v == parent)
        			continue;
        		dfs(a , u , v , b);
        	}
        	if(b[index] == index){
	        	int i;
	        	for(i=0;i<a.get(index).size();i++){
	        		if(b[a.get(index).get(i)] == a.get(index).get(i)){
	        			int u = index;
	        			int v = a.get(index).get(i);
	        			i++;
	        			break;
	        		}
	        	}
	        	i--;
	        	int u = index;
	        	int v = a.get(index).get(i);
	        	int c = b[u];
				b[u] = b[v];
				b[v] = c;
				ans += 2;
			}
        }

        public HashMap<Long , Integer> find(long n){
        	HashMap<Long , Integer> ans = new HashMap<>();
        	for(long i = 2;i*i<=n;i++){
        		if(n%i == 0){
        			int count = 0;
        			while(n%i == 0){
        				n/=i;
        				count++;
        			}
        			ans.put(i , count);
        		}
        	}
        	if(n!=1){
        		ans.put(n , 1);
        	}
        	return ans;
        }

        public void add(HashMap<Integer , HashSet<Integer>> a , int u , int v){
        	if(!a.containsKey(u))
        		a.put(u , new HashSet<>());
        	a.get(u).add(v);
        }

        class Pair{
            long x;
            long y;
            public Pair(long x , long y){
                this.x = x;
                this.y = y;
            }
        }

        class Sort implements Comparator<Pair>{
        	public int compare(Pair a , Pair b){
        		if(a.x < b.x)
        			return -1;
        		if(a.x == b.x && a.y<b.y)
        			return -1;
        		if(a.x == b.x && a.y == b.y)
        			return 0;
        		return 1;
        	}
        }

        public void print1d(char a[] , PrintWriter out){
        	for(int i=0;i<a.length;i++)
        		out.print(a[i]);
        	out.println();
        }

        public int[][] multiply(int a[][] , int b[][]){
            int c[][] = new int[a.length][b[0].length];
            for(int i=0;i<a.length;i++){
                for(int j=0;j<b[0].length;j++){
                    for(int k=0;k<b.length;k++)
                        c[i][j] += a[i][k]*b[k][j];
                }
            }
            return c;
        }

        public int[][] multiply(int a[][] , int b[][] , int mod){
            int c[][] = new int[a.length][b[0].length];
            for(int i=0;i<a.length;i++){
                for(int j=0;j<b[0].length;j++){
                    for(int k=0;k<b.length;k++){
                        c[i][j] += a[i][k]*b[k][j];
                        c[i][j]%=mod;
                    }
                }
            }
            return c;
        }

        public int[][] pow(int a[][] , long b){
            int res[][] = new int[a.length][a[0].length];
            for(int i=0;i<a.length;i++)
                res[i][i] = 1;
            while(b>0){
                if((b&1) == 1)
                    res = multiply(res , a , 10);
                a = multiply(a , a , 10);
                b>>=1;
            }
            return res;
        }

        public int distance(ArrayList<ArrayList<Integer>> a , int u , int v){
            return depth[u]+depth[v] - 2*depth[lca(a , u , v)];
        }

        public int lca(ArrayList<ArrayList<Integer>> a , int u , int v){
            if(depth[v]<depth[u]){
                int x = u;
                u = v;
                v = x;
            }
            int diff = depth[v] - depth[u];
            for(int i=0;i<parentTable[v].length;i++){
                // checking whether the ith bit is set in the diff variable
                if(((diff>>i)&1) == 1)
                    v = parentTable[v][i];
            }
            if(v == u)
                return v;
            for(int i=parentTable[v].length-1;i>=0;i--){
                if(parentTable[u][i] != parentTable[v][i]){
                    v = parentTable[v][i];
                    u = parentTable[u][i];
                }
            }
            return parentTable[u][0];
        }

        // for the min max problems
        public void build(int lookup[][] , int arr[], int n) {
            for (int i = 0; i < n; i++)
                lookup[i][0] = arr[i];
            for (int j = 1; (1 << j) <= n; j++) {
                for (int i = 0; (i + (1 << j) - 1) < n; i++) {
                    if (lookup[i][j - 1] > lookup[i + (1 << (j - 1))][j - 1])
                        lookup[i][j] = lookup[i][j - 1];
                    else
                        lookup[i][j] = lookup[i + (1 << (j - 1))][j - 1];
                }
            }
        }
        public int query(int lookup[][] , int L, int R) {
            int j = (int)(Math.log(R - L + 1)/Math.log(2));
            if (lookup[L][j] >= lookup[R - (1 << j) + 1][j])
                return lookup[L][j];
            else
                return lookup[R - (1 << j) + 1][j];
        }

        // for printing purposes
        public void print1d(int a[] , PrintWriter out){
            for(int i=0;i<a.length;i++)
                out.print(a[i] + " ");
            out.println();
        }
        public void print1d(long a[] , PrintWriter out){
            for(int i=0;i<a.length;i++)
                out.print(a[i] + " ");
            out.println();
        }
        public void print2d(int a[][] , PrintWriter out){
            for(int i=0;i<a.length;i++){
                for(int j=0;j<a[i].length;j++)
                    out.print(a[i][j] + " ");
                out.println();
            }
            // out.println();
        }
        public void print2d(long a[][] , PrintWriter out){
            for(int i=0;i<a.length;i++){
                for(int j=0;j<a[i].length;j++)
                    out.print(a[i][j] + " ");
                out.println();
            }
            // out.println();
        }

        public void sieve(int a[]){
            a[0] = a[1] = 1;
            int i;
            for(i=2;i*i<=a.length;i++){
                if(a[i] != 0)
                    continue;
                a[i] = i;
                for(int k = (i)*(i);k<a.length;k+=i){
                    if(a[k] != 0)
                        continue;
                    a[k] = i;
                }
            }
        }

        public long nCrPFermet(int n , int r , long p){
            if(r==0)
                return 1l;
            // long fact[] = new long[n+1];
            // fact[0] = 1;
            // for(int i=1;i<=n;i++)
            //     fact[i] = (i*fact[i-1])%p;
            long modInverseR = pow(fact[r] , p-2 , p);
            long modInverseNR = pow(fact[n-r] , p-2 , p);
            long w = (((fact[n]*modInverseR)%p)*modInverseNR)%p;
            return w;
        }
        public long pow(long a, long b, long m) {
            a %= m;
            long res = 1;
            while (b > 0) {
                long x = b&1;
                if (x == 1)
                    res = res * a % m;
                a = a * a % m;
                b >>= 1;
            }
            return res;
        }
        public long pow(long a, long b) {
            long res = 1;
            while (b > 0) {
                long x = b&1;
                if (x == 1)
                    res = res * a;
                a = a * a;
                b >>= 1;
            }
            return res;
        }
        public void sortedArrayToBST(TreeSet<Integer> a , int start, int end) {
            if (start > end) {
                return;
            }
            int mid = (start + end) / 2;
            a.add(mid);
            sortedArrayToBST(a, start, mid - 1);
            sortedArrayToBST(a, mid + 1, end);
        }
        public int lowerLastBound(ArrayList<Integer> a , int x){
            int l = 0;
            int r = a.size()-1;
            if(a.get(l)>=x)
                return -1;
            if(a.get(r)<x)
                return r;
            int mid = -1;
            while(l<=r){
                mid = (l+r)/2;
                if(a.get(mid) == x && a.get(mid-1)<x)
                    return mid-1;
                else if(a.get(mid)>=x)
                    r = mid-1;
                else if(a.get(mid)<x && a.get(mid+1)>=x)
                    return mid;
                else if(a.get(mid)<x && a.get(mid+1)<x)
                    l = mid+1;
            }
            return mid;
        }
        public int upperFirstBound(ArrayList<Integer> a , Integer x){
            int l = 0;
            int r = a.size()-1;
            if(a.get(l)>x)
                return l;
            if(a.get(r)<=x)
                return r+1;
            int mid = -1;
            while(l<=r){
                mid = (l+r)/2;
                if(a.get(mid) == x && a.get(mid+1)>x)
                    return mid+1;
                else if(a.get(mid)<=x)
                    l = mid+1;
                else if(a.get(mid)>x && a.get(mid-1)<=x)
                    return mid;
                else if(a.get(mid)>x && a.get(mid-1)>x)
                    r = mid-1;
            }
            return mid;
        }
        public int lowerLastBound(int a[] , int x){
            int l = 0;
            int r = a.length-1;
            if(a[l]>=x)
                return -1;
            if(a[r]<x)
                return r;
            int mid = -1;
            while(l<=r){
                mid = (l+r)/2;
                if(a[mid] == x && a[mid-1]<x)
                    return mid-1;
                else if(a[mid]>=x)
                    r = mid-1;
                else if(a[mid]<x && a[mid+1]>=x)
                    return mid;
                else if(a[mid]<x && a[mid+1]<x)
                    l = mid+1;
            }
            return mid;
        }
        public int upperFirstBound(long a[] , long x){
            int l = 0;
            int r = a.length-1;
            if(a[l]>x)
                return l;
            if(a[r]<=x)
                return r+1;
            int mid = -1;
            while(l<=r){
                mid = (l+r)/2;
                if(a[mid] == x && a[mid+1]>x)
                    return mid+1;
                else if(a[mid]<=x)
                    l = mid+1;
                else if(a[mid]>x && a[mid-1]<=x)
                    return mid;
                else if(a[mid]>x && a[mid-1]>x)
                    r = mid-1;
            }
            return mid;
        }
        public long log(float number , int base){
            return (long) Math.ceil((Math.log(number) / Math.log(base)) + 1e-9);
        }
        public long gcd(long a , long b){
            if(a<b){
                long c = b;
                b = a;
                a = c;
            }
            while(b!=0){
                long c = a;
                a = b;
                b = c%a;
            }
            return a;
        }
        public long[] gcdEx(long p, long q) {
            if (q == 0)
                return new long[] { p, 1, 0 };
            long[] vals = gcdEx(q, p % q);
            long d = vals[0];
            long a = vals[2];
            long b = vals[1] - (p / q) * vals[2];
            // 0->gcd 1->xValue 2->yValue
            return new long[] { d, a, b };
        }
        public void sievePhi(int a[]){
            a[0] = 0;
            a[1] = 1;
            for(int i=2;i<a.length;i++)
                a[i] = i-1;
            for(int i=2;i<a.length;i++)
                for(int j = 2*i;j<a.length;j+=i)
                    a[j] -= a[i];
        }
        public void lcmSum(long a[]){
            int sievePhi[] = new int[(int)1e6 + 1];
            sievePhi(sievePhi);
            a[0] = 0;
            for(int i=1;i<a.length;i++)
                for(int j = i;j<a.length;j+=i)
                    a[j] += (long)i*sievePhi[i];
        }
    }

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

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

    }
}


//package Contest551;

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

public class mainF {
    public static Scanner enter = new Scanner(System.in);
    public static PrintWriter out = new PrintWriter(System.out);
    public static long mod=998244353;
    public static long cnk[][]=new long[(int)2e3+1][(int)2e3+1];
    public static long fact[]=new long[2*(int)2e3+1];
    public static long reverse[]=new long[2*(int)2e3+1];
    public static long deg_2[]=new long[(int)2e3+1];
    public static void main(String[] args) {
        long t=System.currentTimeMillis();
        cnk[0][0]=1;
        for (int i = 1; i <cnk.length ; i++) {
            cnk[0][i]=1;
            for (int j = 1; j <=i ; j++) {
                cnk[j][i]=cnk[j-1][i-1]+cnk[j][i-1];
                cnk[j][i]%=mod;
            }
        }
        fact[0]=1;
        deg_2[0]=1;
        for (int i = 1; i <fact.length ; i++) {
            fact[i]=fact[i-1]*i;
            fact[i]%=mod;
        }
        for (int i = 1; i <deg_2.length ; i++) {
            deg_2[i]=deg_2[i-1]*2;
            deg_2[i]%=mod;
        }
        reverse[1]=1;
        for (int i = 3; i <reverse.length ; i+=2) {
            reverse[i]=bin_pow(fact[i],mod-2,mod);
        }
       /* System.out.println(Arrays.toString(reverse));
        System.out.println(fact[5]);
        System.out.println(reverse[5]);*/
        int n=enter.nextInt();
        int k=enter.nextInt();
        int l=enter.nextInt();
        long ans=0;
        for (int i = k; i <=n ; i++) {
            long tmp=0;
            for (int s = 0,c=1; s <=n-i ; s++,c*=-1) {
                tmp+=cnk[s][n-i]*deg_2[s]*fact[s+i]*fact[s+i]*reverse[2*(s+i)+1]*c;
                tmp%=mod;
               // System.out.println(reverse[2*(s+i)+1]);
            }
            //System.out.println(tmp);
            ans+=cnk[i][n]*deg_2[i]*tmp;
            ans%=mod;
        }
        ans*=l;
        ans%=mod;
        System.out.println(ans);

      //  System.out.println(System.currentTimeMillis()-t);

    }
    public static long bin_pow(long a,long b, long mod){//a^b %mod
        long ans=1;
        while(b!=0){
            if((b&1)==1) ans*=a;
            a*=a;
            ans%=mod;
            a%=mod;
            b>>=1;
        }
        return ans;
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Solution implements Runnable {

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

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

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

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

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

	long modd = 1000000007;

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

	long f(int a, int b) {
		long res = 0;
		boolean evens = a * b % 2 == 0;
		if (evens) {
			res = 2 * a + 2 * b;
		}
		long all = (a - 1) * (b - 1);
		long odd = a / 2 * (b / 2);
		if (evens) {
			res = (res + 4 * (all - odd)) % modd;
		} else {
			res = (res + 4 * odd) % modd;
		}
		long aeven = 0;
		if (a % 2 == 0) aeven = b + 1; else {
			aeven = (b + 2) / 2;
		}
		long aodd = b + 1 - aeven;
		long beven = 0;
		if (b % 2 == 0) beven = a + 1; else {
			beven = (a + 2) / 2;
		}
		long bodd = a + 1 - beven;
		long tmp = aeven * beven % modd + aodd * bodd % modd;
		if (evens) tmp = (tmp + modd - 2) % modd;
		tmp = (tmp + modd - gcd(a, b) - 1) % modd;
		return (res + 2 * tmp) % modd;
	}

	int ans(int w, int h) {
		long ans = 0;
		if (w < h) { int t = w; w = h; h = t; }
		for (int i = 1; i <= h; i++) {
			for (int j = i + 1; j <= h; j++) {
				long t = f(i, j);
				ans = (ans + t * (w - i + 1) * (h - j + 1)) % modd;
				ans = (ans + t * (h - i + 1) * (w - j + 1)) % modd;
			}
		}
		for (int i = 1; i <= h; i++) {
			long t = f(i, i);
			ans = (ans + t * (w - i + 1) * (h - i + 1)) % modd;
		}
		for (int i = h + 1; i <= w; i++) {
			for (int j = 1; j <= h; j++) {
				long t = f(i, j);
				ans = (ans + t * (w - i + 1) * (h - j + 1)) % modd;
			}
		}
		return (int)(ans * 6 % modd);
	}

	void solve() throws Exception {
		int w = nextInt(), h = nextInt();
		out.println(ans(w, h));
	}

	public void run() {
		try {
			Locale.setDefault(Locale.UK);
			in = new BufferedReader(new InputStreamReader(System.in));
			// in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter(System.out);
			// out = new PrintWriter("output.txt");
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) {
		// new Thread(null, new Solution(), "1", 1 << 28).start();
		(new Solution()).run();
	}

}


import java.util.Scanner;

public class Pie {
		public static void main(String args[]){
			Scanner sc = new Scanner(System.in);
			int n = in.nextInt();
			int a[] = new int [n+1];
			int sum[] = new int[n+1];

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

			sum[n] = 0;
			int dp[] = new int [n+1];
			for(int i = n-1; i>=0; i--){

				sum[i] = sum[i+1]+a[i];
				dp[i] = Math.max(dp[i+1], sum[i+1]-dp[i+1]+a[i]);
			}
			System.out.println((sum[0]-dp[0])+" "+dp[0]);
		}
}


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

public class B {

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

    int f(int x) {
        int ret = 0;
        while (x > 0) {
            ret++;
            x >>= 1;
        }
        return ret;
    }

    boolean isPow2(int x) {
        if (x == 0) {
            throw new AssertionError();
        }
        return (x & (x - 1)) == 0;
    }

    void solve() throws IOException {
        int n = nextInt();
        int q = nextInt();

        int[] sz = new int[n + 1];
        sz[1] = 1;
        for (int i = 1; i < n; i++) {
            sz[i + 1] = sz[i] + f(sz[i]);
        }

        int[] up = new int[sz[n] + 1];

        for (int par = 1, child = 1; child <= sz[n]; par++) {
            up[child++] = par;
            if (isPow2(par)) {
                if (child <= sz[n]) {
                    up[child++] = par;
                }
            }
        }

        List<int[]> add = new ArrayList<>();
        List<int[]> ans = new ArrayList<>();

        while (q-- > 0) {
            int type = nextInt();
            if (type == 1) {
                int[] tmp = { nextInt(), nextInt(), nextInt(), nextInt() };
                add.add(tmp);
            } else {
                int[] tmp = { nextInt(), nextInt() };
                ans.add(tmp);
            }
        }

        int[] outp = new int[ans.size()];
        Set<Integer> set = new HashSet<>();

        for (int level = n; level >= 1; level--) {
            for (int i = 0; i < ans.size(); i++) {
                if (ans.get(i)[0] == level) {
                    set.clear();
                    int pos = ans.get(i)[1];
                    for (int j = 0; j < add.size(); j++) {
                        int[] tmp = add.get(j);
//                      System.err.println(level + " " + pos);
//                      System.err
//                              .println(tmp[0] + " " + tmp[1] + " " + tmp[2]);
                        if (tmp[0] == level && tmp[1] <= pos && pos <= tmp[2]) {
                            set.add(tmp[3]);
                        }
                    }
                    outp[i] = set.size();
                }
            }

            for (int i = 0; i < add.size(); i++) {
                int[] tmp = add.get(i);
                if (tmp[0] == level) {
                    tmp[0]--;
                    tmp[1] = up[tmp[1]];
                    tmp[2] = up[tmp[2]];
                }
            }

        }

        for (int x : outp) {
            out.println(x);
        }

    }

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

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

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

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

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

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

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


import java.util.*;
public class Task {

    public static long max(long a, long b ) {
        if(a < b) {
            return b;
        }
        return a;
    }

    public static int max(int a, int b ) {
        if(a < b) {
            return b;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] beauty = new int[200005];
        for(int i = 0; i < n; i++) {
            beauty[i] = sc.nextInt();
        }
        sc.nextLine();
        String str = sc.nextLine();
        int rcn = 0;
        int wcn = 0;
        int ocn = 0;
        int rsum = 0;
        int wsum = 0;
        int osum = 0;
        ArrayList<Integer> wo = new ArrayList<Integer>();
        ArrayList<Integer> ro = new ArrayList<Integer>();
        int maxo = 0;
        int maxr = 0;
        int maxw = 0;
        for(int i = 0; i < n; i++) {
            if(str.charAt(i) == 'R') {
                maxr = max(maxr,beauty[i]);
                rcn++;
                ro.add(beauty[i]);
                rsum+= beauty[i];
            }
            if(str.charAt(i) == 'W') {
                maxw = max(maxw,beauty[i]);
                wcn++;
                wo.add(beauty[i]);
                wsum+= beauty[i];
            }
            if(str.charAt(i) == 'O') {
                maxo = max(maxo,beauty[i]);
                ocn++;
                ro.add(beauty[i]);
                wo.add(beauty[i]);
                osum+= beauty[i];
            }
        }
        ro.remove(ro.indexOf(maxr));
        ro.remove(ro.indexOf(maxo));
        wo.remove(wo.indexOf(maxw));
        wo.remove(wo.indexOf(maxo));
        if(k == 1 || ocn == 0 || max(ocn+wcn,ocn+rcn) < k) {
            System.out.print(-1);
        } else {
            Collections.sort(ro);
            Collections.sort(wo);
            long ans1 = maxr+maxo;
            long ans2 = maxw+maxo;
            if(ro.size()+2 >= k) {
                for(int i = ro.size()-1; i >= ro.size()-k+2; i--) {
                    ans1+= ro.get(i);
                }
            }
            if(wo.size()+2 >= k) {
                for(int i = wo.size()-1; i >= wo.size()-k+2; i--) {
                    ans2+= wo.get(i);
                }
            }
            System.out.print(max(ans1,ans2));
        }
    }
}


import static java.lang.Math.abs;
import static java.lang.System.out;
import java.util.Scanner;

// 795A
// n people, some pupil, some adult. separate into groups. a group must have 1 adult
// if a group has x people, cost of tickets=c1+c2(x-1)^2
// optimize grouping to find minimal price
// IDEA: binary search, local minimum may not be the best answer as we may have picked the wrong half
//  need to verify if there is no better solution
public class AmusementPark {

    int adult;
    int pupil;
    int n;      // 1 ≤ n ≤ 200 000
    long c1;    // 1 ≤ c1, c2 ≤ 10^7
    long c2;    // use long type to avoid overflow in calculation
    long minCost=0;

    long formula(int x)
    {
        return c1+c2*(x-1)*(x-1);
    }
    long calc(int group)
    {
        if (group==1)
        {
            return formula(n);
        }
        int avg = n/group;
        int rem = n%group;
        long cost = formula(avg);
        cost *= (group-rem);
        return cost + rem*formula(avg+1);
    }
    long cost(int lo, int hi, long lowCost, long hiCost)
    {
        if (abs(lo-hi)<=1) {
            //out.println("first "+lo+" second "+hi+" low clost "+lowCost+" hi cost "+hiCost);
            if (lo>1) {
                long c=calc(lo-1);
                if (c<lowCost)
                    return cost(lo-1, 1, c, calc(1));
            }
            if (lo<adult) {
                long c=calc(lo+1);
                if (c<lowCost)
                    return cost(lo+1, adult, c, calc(adult));
            }
            return lowCost;
        }
        int mid = (lo+hi)/2;
        long midCost = calc(mid);
        //out.println("first "+lo+" second "+hi+ " mid cost "+midCost+" low clost "+lowCost+" hi cost "+hiCost);
        if (midCost<lowCost)
            return cost(mid, lo, midCost, lowCost);
        else if ( midCost > lowCost )
            return cost(lo, mid, lowCost, midCost);
        else {
            //out.println("bad mid cost "+midCost+" low clost "+lowCost+" hi cost "+hiCost);
            return midCost;
        }
    }
    AmusementPark(int a, int p, int c1, int c2)
    {
        adult = a;
        pupil = p;
        n = a+p;
        this.c1 = c1;
        this.c2 = c2;
        long cost1 = calc(1);
        long cost2 = calc(a);
        if (cost1>cost2)
            cost1=cost(a, 1, cost2, cost1);
        else if (cost1<cost2)
            cost1=cost(1, a, cost1, cost2);
        out.println(cost1);
    }

    static Scanner scan = new Scanner(System.in);
    static void judge()
    {
        int n = scan.nextInt();  // between 1 and 20000
        int c1 = scan.nextInt();  // between 1 and 10^7
        int c2 = scan.nextInt();  // between 1 and 10^7
        String people = scan.nextLine();
        if (people.isEmpty())
            people = scan.nextLine();
        int pupil=0;
        int adult=0;
        for(int i=0; i<people.length(); i++)
        {
            if (people.charAt(i)=='1')
                adult++;
            else
                pupil++;
        }
        new AmusementPark(adult, pupil, c1, c2);
    }
    static void test()
    {
        new AmusementPark(9559, 10442, 1000, 100); // 9333800
        new AmusementPark(9, 1, 2, 2); // 20
    }
    public static void main(String[] args)
    {
        judge();
    }
}
/*
10 2 2
1111101111
ans 20
*/


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

import Solution3.InputReader;

public class PrimeProblem {

	private void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt();
		int sum = n*(n+1)/2;
		HashSet<Integer> primes = getPrimes(sum);
		int[] colors = new int[n];
		boolean isColored = false;
		if (primes.contains(sum)) isColored = true;
		if (!isColored) {
			for (Integer prime: primes) {
				if (primes.contains(sum-prime)) {
					int left = prime;
					for (int i = n; i>= 1; i--) {
						if (i <= left) {
							colors[i-1] = 1;
							left-=i;
						}
					}
					isColored = true;
					break;
				}
			}
		}
		if (!isColored) {
			for (Integer prime: primes) {
				if (primes.contains(sum-prime-3)) {
					colors[2]=2;
					int left = prime;
					for (int i = n; i>= 1; i--) {
						if (i == 2) continue;
						if (i <= left) {
							colors[i-1] = 1;
							left-=i;
						}
					}
					break;
				}
			}
		}
		for (int c: colors) {
			out.print((c+1) + " ");
		}
		out.println();
	}

	private static HashSet<Integer> getPrimes(int sum) {
		int[] p = new int[sum+1];
		for (int i = 2; i < p.length; i++) {
			if (p[i] == 1) continue;
			for (int j = i+i; j < p.length; j+=i) {
				p[j] = 1;
			}
		}
		HashSet<Integer> result = new HashSet<>(1000000);
		for (int i = 2; i < p.length; i++) {
			if (p[i] == 1) continue;
			result.add(i);
		}
		return result;
	}

	public static void main(String[] args) throws Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		PrimeProblem solver = new PrimeProblem();
		solver.solve(in, out);
		out.close();
	}

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

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

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

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 *
 * @author pttrung
 */
public class D_Round_173_Div2 {

	public static long MOD = 1000000007;

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		int[] data = new int[n];
		for (int i = 0; i < n; i++) {
			data[i] = in.nextInt();
		}
		Arrays.sort(data);
		if (n == 1) {
			if (data[0] == 0) {
				out.println("BitAryo");
			} else {
				out.println("BitLGM");
			}
		} else if (n == 2) {
			int[][][] dp = new int[2][data[0] + 1][data[1] + 1];
			for (int[][] a : dp) {
				for (int[] b : a) {
					Arrays.fill(b, -1);
				}
			}
			int r = cal(0, data[0], data[1], dp);
			if (r == 0) {
				out.println("BitLGM");
			} else {
				out.println("BitAryo");
			}
		} else {
			int[][][][] dp = new int[2][data[0] + 1][data[1] + 1][data[2] + 1];
			for (int[][][] a : dp) {
				for (int[][] b : a) {
					for (int[] c : b)
						Arrays.fill(c, -1);
				}
			}
			int r = cal2(0, data[0], data[1], data[2], dp);
			if (r == 0) {
				out.println("BitLGM");
			} else {
				out.println("BitAryo");
			}
		}
		out.close();
	}

	static int cal(int index, int a, int b, int[][][] dp) {
		if (a == 0 && b == 0) {
			return 1 - index;
		}
		if (dp[index][a][b] != -1) {
			return dp[index][a][b];
		}
		int result = 1 - index;
		for (int i = 1; i <= a; i++) {
			int x = Math.min(a - i, b);
			int y = Math.max(a - i, b);
			int v = cal(1 - index, x, y, dp);
			if (v == index) {
				result = index;
				break;
			}
		}
		if (result != index) {
			for (int i = 1; i <= b; i++) {
				int x = Math.min(b - i, a);
				int y = Math.max(b - i, a);
				int v = cal(1 - index, x, y, dp);
				if (v == index) {
					result = index;
					break;
				}
			}
			if (result != index) {
				for (int i = 1; i <= Math.min(a, b); i++) {
					int x = Math.min(b - i, a - i);
					int y = Math.max(b - i, a - i);
					int v = cal(1 - index, x, y, dp);
					if (v == index) {
						result = index;
						break;
					}
				}
			}
		}
		return dp[index][a][b] = result;
	}

	static int cal2(int index, int a, int b, int c, int[][][][] dp) {

		if (a == 0) {
			if ((b ^ c) == 0)
				return 1 - index;
			return index;
		}
		if (dp[index][a][b][c] != -1) {
			return dp[index][a][b][c];
		}
		int result = 1 - index;
		if ((a ^ b ^ c) != 0) {
			result = index;
		}

		if (result != index) {
			for (int i = 1; i <= a; i++) {

				int v = cal2(1 - index, a - i, b - i, c - i, dp);
				if (v == index) {
					result = index;
					break;
				}
			}
		}

		return dp[index][a][b][c] = result;
	}

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return x - o.x;
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

	public static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

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

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

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

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

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.InputMismatchException;

/**
 * @author Egor Kulikov (egor@egork.net)
 *         Created on 14.03.2010
 */
public class TaskE implements Runnable {
	private InputReader in;
	private PrintWriter out;
	private static final long MOD = 1000000009;

	public static void main(String[] args) {
		new Thread(new TaskE()).start();
//		new Template().run();
	}

	public TaskE() {
//		String id = getClass().getName().toLowerCase();
//		try {
//			System.setIn(new FileInputStream(id + ".in"));
//			System.setOut(new PrintStream(new FileOutputStream(id + ".out")));
//			System.setIn(new FileInputStream("input.txt"));
//			System.setOut(new PrintStream(new FileOutputStream("output.txt")));
//		} catch (FileNotFoundException e) {
//			throw new RuntimeException();
//		}
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
	}

	public void run() {
//        int numTests = in.readInt();
//        for (int testNumber = 0; testNumber < numTests; testNumber++) {
//			out.print("Case #" + (testNumber + 1) + ": ");
//        }
		int n = in.readInt();
		long[] d = new long[n + 1];
		d[0] = 1;
		for (int i = 1; i <= n; i++)
			d[i] = (2 * d[i - 1]) % MOD;
		long[] c = new long[n + 1];
		c[0] = 1;
		for (int i = 1; i <= n; i++)
			c[i] = (c[i - 1] + 2 * d[i]) % MOD;
		long[] b = new long[n + 1];
		b[0] = 1;
		for (int i = 1; i <= n; i++) {
			if (i % 2 == 1 && i > 1)
				b[i] = (b[i - 1] * c[i / 2 - 1]) % MOD;
			else
				b[i] = b[i - 1];
		}
		long[] a = new long[n + 1];
		a[1] = 0;
		for (int i = 2; i <= n; i++)
			a[i] = (a[i - 1] + 2 * b[i - 1]) % MOD;
		long ans = (a[n] * a[n] + 1) % MOD;
		ans = (ans * 2) % MOD;
		out.println(ans);
		out.close();
	}

	private static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1000];
		private int curChar, numChars;

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

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

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

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

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

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

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

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

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

		public BigInteger readBigInteger() {
			try {
				return new BigInteger(readString());
			} catch (NumberFormatException e) {
				throw new InputMismatchException();
			}
		}

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

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


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

public class Main {
    public void solve() {
        int a = ni(), b = ni(), c = ni(), l = ni();
        int x, y ,z;
        if ((a > b) && (a > c)) {
            x = a;
            if (b > c) {
                y = b;
                z = c;
            } else {
                y = c;
                z = b;
            }
        } else if (b > c) {
            x = b;
            if (a > c) {
                y = a;
                z = c;
            } else {
                y = c;
                z = a;
            }
        } else {
            x = c;
            if (b > a) {
                y = b;
                z = a;
            } else {
                y = a;
                z = b;
            }
        }

        long ans = 0;
        for (int i = x; l - (i - x) - (Math.max(0, i - (y + z) + 1)) >= 0; i++) {
            for (int j = y; l - (i - x) - (j - y) - (Math.max(0, j - (i + z) + 1)) >= 0; j++) {
//                System.out.println(i + " " + j + " " + (l - (i - x) - (j - y)));
                int max = (i + j - 1);
                int min = Math.abs(i - j) + 1;
//                System.out.println("min: " + min + " max: " + max);
                int steps = l - (i - x) - (j - y) - Math.max(0, min - z);
                max = Math.min(max, min + steps);
                ans += Math.max(0, max - min + 1);
//                System.out.println(Math.max(0, max - min + 1));
            }
        }
        write(ans + "\n");
    }

    public static void main(String[] args){
        Main m = new Main();
        m.solve();
        try {
            m.writer.close();
        } catch (IOException e) {};
    }
    BufferedReader reader;
    BufferedWriter writer;
    StringTokenizer tokenizer;
    public Main() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        writer = new BufferedWriter(new OutputStreamWriter(System.out));
    }
    int ni() {
        return Integer.parseInt(n());
    }
    String n() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {}
        }
        return tokenizer.nextToken();
    }
    void write(String s) {
        try {
            writer.write(s);
        } catch(IOException e) {};
    }
}