import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.InputStream;

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

    static class TaskD {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            final int inf = 1000;
            int n, m;
            int[][] dist;
            IntArrayList[] gr;

            n = in.readInt();
            m = in.readInt();
//        n = 400;

            dist = new int[n][n];
            ArrayUtils.fill(dist, inf);
            gr = new IntArrayList[n];
            for (int v = 0; v < n; v++) {
                dist[v][v] = 0;
                gr[v] = new IntArrayList();
            }

            for (int iter = 0; iter < m; iter++) {
                int a = in.readInt() - 1;
                int b = in.readInt() - 1;
                dist[a][b] = dist[b][a] = 1;
                gr[a].add(b);
                gr[b].add(a);
            }

//        for (int a = 0; a < n; a++) {
//            for (int b = a + 1; b < n; b++) {
//                dist[a][b] = dist[b][a] = 1;
//                gr[a].add(b);
//                gr[b].add(a);
//            }
//        }

            for (int k = 0; k < n; k++) {
                for (int v = 0; v < n; v++) {
                    for (int to = 0; to < n; to++) {
                        dist[v][to] = Math.min(dist[v][to], dist[v][k] + dist[k][to]);
                    }
                }
            }

            boolean[] used = new boolean[n];
            IntArrayList citiesBear0 = new IntArrayList(n);
            int szCitiesBear1;
            int[] citiesBear1 = new int[n];

            double dp = 0;
            for (int v0 = 0; v0 < n; v0++) {
                double dp_V0 = 0;
                for (int d0 = 0; d0 < n; d0++) {

                    while (0 < citiesBear0.size()) {
                        citiesBear0.popLast();
                    }
                    szCitiesBear1 = 0;
                    Arrays.fill(used, false);

                    for (int cityBear0 = 0; cityBear0 < n; cityBear0++) {
                        if (dist[v0][cityBear0] == d0) {
                            citiesBear0.add(cityBear0);
                            for (int cityBear1 : gr[cityBear0]) {
                                if (!used[cityBear1]) {
                                    used[cityBear1] = true;
                                    citiesBear1[szCitiesBear1++] = cityBear1;
                                }
                            }
                        }
                    }

                    if (citiesBear0.size() == 0) {
                        continue;
                    }

                    double dp_V0_D0 = 0;
                    double coef = 1. / citiesBear0.size();
                    if (d0 != 0) {
                        double[] probV = new double[n];
                        for (int b0 : citiesBear0) {
                            double invSize = 1. / gr[b0].size();
                            for (int b1 : gr[b0]) {
                                probV[b1] += coef * invSize;
                            }
                        }

                        double[] probD = new double[n];
                        for (int v1 = 0; v1 < n; v1++) {
                            int[] dist_v1 = dist[v1];
                            for (int i = 0; i < szCitiesBear1; i++) {
                                int b1 = citiesBear1[i];
                                int d1 = dist_v1[b1];
                                probD[d1] = max(probD[d1], probV[b1]);
                            }
                            double dp_V0_D0_V1 = 0;
                            for (int i = 0; i < szCitiesBear1; i++) {
                                int b1 = citiesBear1[i];
                                int d1 = dist_v1[b1];
                                dp_V0_D0_V1 += probD[d1];
                                probD[d1] = 0;
                            }
                            dp_V0_D0 = max(dp_V0_D0, dp_V0_D0_V1);
                        }
                    }
                    dp_V0_D0 = max(dp_V0_D0, coef);

                    dp_V0 += ((double) citiesBear0.size() / n) * dp_V0_D0;
                }
                dp = max(dp, dp_V0);
            }
            out.printFormat("%.12f", dp);
            out.printLine();
        }

        static private double max(double a, double b) {
            return a < b ? b : a;
//        return Math.max(a, b);
        }

    }

    static interface IntStream extends Iterable<Integer>, Comparable<IntStream> {
        public IntIterator intIterator();

        default public Iterator<Integer> iterator() {
            return new Iterator<Integer>() {
                private IntIterator it = intIterator();

                public boolean hasNext() {
                    return it.isValid();
                }

                public Integer next() {
                    int result = it.value();
                    it.advance();
                    return result;
                }
            };
        }

        default public int compareTo(IntStream c) {
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                int i = it.value();
                int j = jt.value();
                if (i < j) {
                    return -1;
                } else if (i > j) {
                    return 1;
                }
                it.advance();
                jt.advance();
            }
            if (it.isValid()) {
                return 1;
            }
            if (jt.isValid()) {
                return -1;
            }
            return 0;
        }

    }

    static interface IntCollection extends IntStream {
        public int size();

        default public void add(int value) {
            throw new UnsupportedOperationException();
        }

        default public IntCollection addAll(IntStream values) {
            for (IntIterator it = values.intIterator(); it.isValid(); it.advance()) {
                add(it.value());
            }
            return this;
        }

    }

    static class IntArrayList extends IntAbstractStream implements IntList {
        private int size;
        private int[] data;

        public IntArrayList() {
            this(3);
        }

        public IntArrayList(int capacity) {
            data = new int[capacity];
        }

        public IntArrayList(IntCollection c) {
            this(c.size());
            addAll(c);
        }

        public IntArrayList(IntStream c) {
            this();
            if (c instanceof IntCollection) {
                ensureCapacity(((IntCollection) c).size());
            }
            addAll(c);
        }

        public IntArrayList(IntArrayList c) {
            size = c.size();
            data = c.data.clone();
        }

        public IntArrayList(int[] arr) {
            size = arr.length;
            data = arr.clone();
        }

        public int size() {
            return size;
        }

        public int get(int at) {
            if (at >= size) {
                throw new IndexOutOfBoundsException("at = " + at + ", size = " + size);
            }
            return data[at];
        }

        private void ensureCapacity(int capacity) {
            if (data.length >= capacity) {
                return;
            }
            capacity = Math.max(2 * data.length, capacity);
            data = Arrays.copyOf(data, capacity);
        }

        public void addAt(int index, int value) {
            ensureCapacity(size + 1);
            if (index > size || index < 0) {
                throw new IndexOutOfBoundsException("at = " + index + ", size = " + size);
            }
            if (index != size) {
                System.arraycopy(data, index, data, index + 1, size - index);
            }
            data[index] = value;
            size++;
        }

        public void removeAt(int index) {
            if (index >= size || index < 0) {
                throw new IndexOutOfBoundsException("at = " + index + ", size = " + size);
            }
            if (index != size - 1) {
                System.arraycopy(data, index + 1, data, index, size - index - 1);
            }
            size--;
        }

    }

    static interface IntReversableCollection extends IntCollection {
    }

    static interface IntList extends IntReversableCollection {
        public abstract int get(int index);

        public abstract void addAt(int index, int value);

        public abstract void removeAt(int index);

        default public IntIterator intIterator() {
            return new IntIterator() {
                private int at;
                private boolean removed;

                public int value() {
                    if (removed) {
                        throw new IllegalStateException();
                    }
                    return get(at);
                }

                public boolean advance() {
                    at++;
                    removed = false;
                    return isValid();
                }

                public boolean isValid() {
                    return !removed && at < size();
                }

                public void remove() {
                    removeAt(at);
                    at--;
                    removed = true;
                }
            };
        }

        default public void add(int value) {
            addAt(size(), value);
        }

        default public void popLast() {
            removeAt(size() - 1);
        }

    }

    static class ArrayUtils {
        public static void fill(int[][] array, int value) {
            for (int[] row : array) {
                Arrays.fill(row, value);
            }
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

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

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

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

        public void printFormat(String format, Object... objects) {
            writer.printf(format, objects);
        }

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

    }

    static abstract class IntAbstractStream implements IntStream {

        public String toString() {
            StringBuilder builder = new StringBuilder();
            boolean first = true;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                if (first) {
                    first = false;
                } else {
                    builder.append(' ');
                }
                builder.append(it.value());
            }
            return builder.toString();
        }

        public boolean equals(Object o) {
            if (!(o instanceof IntStream)) {
                return false;
            }
            IntStream c = (IntStream) o;
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                if (it.value() != jt.value()) {
                    return false;
                }
                it.advance();
                jt.advance();
            }
            return !it.isValid() && !jt.isValid();
        }

        public int hashCode() {
            int result = 0;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                result *= 31;
                result += it.value();
            }
            return result;
        }

    }

    static interface IntIterator {
        public int value() throws NoSuchElementException;

        public boolean advance();

        public boolean isValid();

    }

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

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

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

        public 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 boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

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

        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class PanterRobot {

	static class Scanner{
		BufferedReader br=null;
		StringTokenizer tk=null;
		public Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		public String next() throws IOException{
			while(tk==null || !tk.hasMoreTokens())
				tk=new StringTokenizer(br.readLine());
			return tk.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException{
			return Integer.valueOf(next());
		}
		public double nextDouble() throws NumberFormatException, IOException{
			return Double.valueOf(next());
		}
	}

	static int N,M;
	static HashSet<State> visited;

	static class State{
		int x,y,dir;
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + x;
			result = prime * result + y;
			return result;
		}
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			State other = (State) obj;
			if (x != other.x)
				return false;
			if (y != other.y)
				return false;
			return true;
		}
		public State(int xx, int yy, int dirr){
			x = xx;
			y = yy;
			dir = dirr;
		}
		public String toString(){
			return String.format("(%d, %d, %d)", x, y, dir);
		}
	}

	static int getCode(String ins){
		if (ins.equals("UL"))
			return 3;
		if (ins.equals("UR"))
			return 2;
		if (ins.equals("DL"))
			return 1;
		if (ins.equals("DR"))
			return 0;
		return (0 / 0);
	}

	public static void main(String args[]) throws NumberFormatException, IOException{
		Scanner sc = new Scanner();
		N = sc.nextInt();
		M = sc.nextInt();
		int amount = N + M - 2;
		long ans = 0;
		boolean finished = false;
		int a  = sc.nextInt();
		int b = sc.nextInt();
		int c = getCode(sc.next());
		State current = new State(a, b, c);
		HashSet<State>  visited = new HashSet<State>();
		if (N == M && M == 3){
			if (a == 1 &&  b == 1){
				System.out.println("-1");
				return;
			}
			if (a == 3 &&  b == 1){
				System.out.println("-1");
				return;
			}
			if (a == 1 &&  b == 3){
				System.out.println("-1");
				return;
			}
			if (a == 3 &&  b == 3){
				System.out.println("-1");
				return;
			}
		}
		if(N == M && M > 3){
			System.out.println("-1");
			return;
		}
		while(true){
			visited.add(current);
			if (visited.size() == amount) {
				finished = true;
				break;
			}
			int nx = 0,ny = 0,ndir = 0;
			if (current.dir == 0){
				int dy = M - current.y;
				int dx = N - current.x;
				if ( dy < dx){
					nx = current.x + dy;
					ny = M;
					ndir = getCode("DL");
				}
				else if (dy > dx){
					nx = N;
					ny = current.y + dx;
					ndir = getCode("UR");
				}
				else{
					//iguales
					nx = N;
					ny = M;
					ndir = getCode("UL");
				}
				ans += Math.min(dx, dy);
			}
			else if (current.dir == 1){
				int dy = current.y - 1;
				int dx = N - current.x;
				if ( dy < dx){
					nx = current.x + dy;
					ny = 1;
					ndir = getCode("DR");
				}
				else if (dy > dx){
					nx = N;
					ny = current.y - dx;
					ndir = getCode("UL");
				}
				else{
					//iguales
					nx = N;
					ny = 1;
					ndir = getCode("UR");
				}
				ans += Math.min(dx, dy);
			}
			else if (current.dir == 2){
				int dy = M - current.y;
				int dx = current.x - 1;
				if ( dy < dx){
					nx = current.x - dy;
					ny = M;
					ndir = getCode("UL");
				}
				else if (dy > dx){
					nx = 1;
					ny = current.y + dx;
					ndir = getCode("DR");
				}
				else{
					//iguales
					nx = 1;
					ny = M;
					ndir = getCode("DL");
				}
				ans += Math.min(dx, dy);
			}
			else if (current.dir == 3){
				int dy = current.y - 1;
				int dx = current.x - 1;
				if ( dy < dx){
					nx = current.x - dy;
					ny = 1;
					ndir = getCode("UR");
				}
				else if (dy > dx){
					nx = 1;
					ny = current.y - dx;
					ndir = getCode("DL");
				}
				else{
					//iguales
					nx = 1;
					ny = 1;
					ndir = getCode("DR");
				}
				ans += Math.min(dx, dy);
			}
			else
				System.out.println(0 / 0);
			current = new State(nx, ny, ndir);
			//System.out.println(ans);
			//System.out.println(current);
		}
		if (finished)
			System.out.println(ans + 1);
		else
			System.out.println("-1");
	}

}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class popo {

    public static boolean prime[];
    public static ArrayList[] ad=new ArrayList[2555];
    public static ArrayList<Long> xor1,xor2;
    static int []min;
    static char [][]grid;
    static int []dx = {0,0,-1,1};
    static int []dy = {-1,1,0,0};
    static int []dx8 = {1,1,1,0,-1,-1,-1,0};
    static int []dy8 = {1,0,-1,-1,-1,0,1,1};
    static ArrayList<Point> aa;

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

        int t = in.nextInt();
        while (t-->0)
          {
              long a = in.nextLong();
              long b = in.nextLong();
              boolean k =winner(a,b);
              if(k)
                  out.println("First");
              else
                  out.println("Second");

        }

        out.close();
    }
    static boolean winner(long a  ,long b)
    {
        if(a==0 || b==0)
            return false;
        if(a>b)
        {
            long t = a;
            a = b;
            b = t;
        }
        if(!winner(a,b%a))return true;
        long mod = b/a;
         a = a+1;
        return ((mod)%2 == 0);
    }

    public static long modPow(long base, long exp, long mod) {
        base = base % mod;
        long result = 1;
        while(exp > 0)
        {
            if(exp % 2== 1)
            {
                result = (result * base) % mod;
                exp --;
            }
            else
            {
                base = (base * base) % mod;
                exp = exp >> 1;
            }

        }
        return result;
    }

    public static long mod = 1000000007, inf = 100000000000000000l;
    public static long fac[],inv[];
    public static void cal()
    {
        fac = new long[100001];
        inv = new long[100001];
        fac[0]=1;
        inv[0]=1;
        for(int i=1; i<=100000; i++)
        {
            fac[i]=(fac[i-1]*i)%mod;
            //  inv[i]=(inv[i-1]*modPow(i,mod-2,mod))%mod;

        }
    }
    public static long combination(long n, long r)
    {
        long k = (fac[(int) n]%mod*inv[(int) r]%mod)%mod;
        long p = inv[(int) (n-r)]%mod;
        long m = (k*p)%mod;
        return m;
    }

    public static class Point implements Comparable<Point> {

        long x, y;

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

        @Override
        public int hashCode() {
            int hash = 5;
            hash = (int) (47 * hash + this.x);
            hash = (int) (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 Long.compare(x, o.x);
        }
    }
    static long setbits(long i)
    {
        long count = 0;
        while (i>0)
        {
            count += i & 1;
            i >>= 1;
        }
        return count;

    }

    static ArrayList<Long> sieveOfEratosthenes(int n)
    {
        // Create a boolean array "prime[0..n]" and initialize
        // all entries it as true. A value in prime[i] will
        // finally be false if i is Not a prime, else true.

        prime=new boolean[1000001];
        for(int i=0;i<n;i++)
            prime[i] = true;

        for(long p = 2; p*p <=n; p++)
        {
            // If prime[p] is not changed, then it is a prime
            if(prime[(int)p] == true)
            {
                // Update all multiples of p
                for(long i = p*2; i <= n; i += p) {
                    prime[(int) i] = false;
                }
            }
        }
        ArrayList<Long> aa=new ArrayList<>();
        for (long i=0;i<n;i++)
        {
            if(prime[(int)i])
                aa.add(i);
        }
        return aa;

        // Print all prime numbers
      /*  for(int i = 2; i <= n; i++)
        {
            if(prime[i] == true)
                System.out.print(i + " ");
        }
       */
    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private InputReader.SpaceCharFilter filter;

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

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

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

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

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

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

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

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


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

public class E {

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

    int hNum, mNum, k, newHourK;
    int newDayChange;

    long pow10;
    long pow10Hour;

    long go(int h, int m) {
        // good moments from (0, 0) to (h, m)
        //System.err.println(h + " " + m + " ");
        if (m < 0) {
            m += mNum;
            h--;
        }

        if (h < 0)
            return 0;

        long res = 0;

        // when hour doesn't change

        // first h full hours
        res += (long)h * ((mNum - 1) / pow10);

        //System.err.println(res);

        //last hour also full
        if (m == mNum - 1)
            res += (mNum - 1) / pow10;
        //last hour not full
        else
            res += (m + 1) / pow10;

        //hour also changes
        //in fact everything is the same, but we use newHourK instead of k
        if (m != mNum - 1)
            h--;

        //hour changes for hours [0, h]

        if (h == hNum - 1) {
            if (newDayChange >= newHourK)
                res++;
            h--;
        }
        // if it's full day, last change must be treated separately
        res += (h + 1) / pow10Hour;

        //System.err.println(res);

        return res;
    }

    void solve() throws IOException {
        hNum = nextInt();
        mNum = nextInt();
        k = nextInt();

        int h1 = nextInt();
        int m1 = nextInt();

        int h2 = nextInt();
        int m2 = nextInt();

        int newHourChange = 0;

        String s = Integer.toString(mNum - 1);
        for (int i = 0; i < s.length(); i++)
            if (s.charAt(i) != '0')
                newHourChange++;

        pow10 = 1;
        for (int i = 0; i < k - 1; i++)
            pow10 *= 10;

        newHourK = Math.max(k - newHourChange, 1);

        pow10Hour = 1;
        for (int i = 0; i < newHourK - 1; i++)
            pow10Hour *= 10;

        newDayChange = 0;
        s = Integer.toString(hNum - 1);
        for (int i = 0; i < s.length(); i++)
            if (s.charAt(i) != '0')
                newDayChange++;

        if (h1 < h2 || (h1 == h2 && m1 <= m2))
            // good moments from (h1,m1) to (h2,m2-1)
            out.print(go(h2, m2 - 1) - go(h1, m1 - 1));
        else
            // good moments from (h1, m1) to (hNum - 1, mNum - 1) and from (0, 0) to (h2, m2 - 1)
            out.print(go(hNum - 1, mNum - 1) - go(h1, m1 - 1) + go(h2, m2 - 1));
    }

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

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

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

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

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

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

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

}


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

public class C {

	static final int INF = Integer.MAX_VALUE / 3;
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	static int N = 1_000_000;
	static int ROOT = 1_000;
	static boolean[] isPrime = new boolean[N + 1];
	static List<Integer> primes = new ArrayList<>(78498);
	static {
		Arrays.fill(isPrime, true);
		for (int i = 2; i <= N; i++) {
			if (isPrime[i]) {
				primes.add(i);
				if (i <= ROOT) {
					for (int j = i * i; j <= N; j += i) {
						isPrime[j] = false;
					}
				}
			}
		}
	}

	int n;
	long[] a;

	void solve() throws IOException {
		n = nextInt();
		a = new long[n];

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

		Arrays.sort(a);

		int ans = go(n - 1, new ArrayList<Long>(), 0);
		out.println(ans);
	}

	int go(int i, List<Long> vs, int roots) {
		if (i == -1) {
			int ret = 0;

			for (long x : vs) {
				int val = sumPrimePowers(x);
				ret += val + 1;
			}

			if (roots > 1)
				ret++;

			return ret;
		}

		int ret = Integer.MAX_VALUE;

		long add = a[i];
		for (int j = 0; j < vs.size(); j++) {
			if (vs.get(j) % add == 0) {
				List<Long> newVs = new ArrayList<>(vs);

				newVs.set(j, vs.get(j) / add);
				if (sumPrimePowers(add) > 1) {
					newVs.add(add);
				} else {
					newVs.add(1L);
				}
				ret = Math.min(ret, go(i - 1, newVs, roots));
			}
		}
		if (sumPrimePowers(add) == 1) {
			vs.add(1L);
		} else {
			vs.add(add);
		}
		ret = Math.min(ret, go(i - 1, vs, roots + 1));
		return ret;
	}

	int sumPrimePowers(long x) {
		int ret = 0;
		for (int i = 0; i < primes.size() && x > 1; i++) {
			int p = primes.get(i);
			while (x % p == 0) {
				x /= p;
				ret++;
			}
		}
		if (x != 1)
			ret++;
		return ret;
	}

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

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

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

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

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

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

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


import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class Main {
    public static void main(String[]args){
    new Main().run();
    }
    void run(){
    Scanner sc=new Scanner(System.in);
    long a=sc.nextLong(),l=sc.nextLong()-1;
    long res=func(a,l);
    System.out.println(res);
    }
    private long func(long a,long l){// [a,a+l]
    if(l>20){
        return a%10 + func(a/10,l/10 + (a%10+l%10)/10)*10;
    }
    int[] cnt=new int[(int)(l+1)];
    for (int i = 0; i<l+1; i++) {
        cnt[i]=lucky(a+i);
    }
    return func2(a+1,cnt);
    }
    private int lucky(long l) {
    int res=0;
    while(l>0){
        if(l%10==4||l%10==7)res++;
        l/=10;
    }
    return res;
    }
    long INF=1L<<60;
    class E{
    long min;
    int[] cnt;
    E(long min,int[] cnt){
        this.min=min;
        this.cnt=cnt;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj==null) return false;
        if (getClass()!=obj.getClass()) return false;
        final E other = (E) obj;
        if (this.min!=other.min) return false;
        if (!Arrays.equals(this.cnt, other.cnt)) return false;
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67*hash+(int) (this.min^(this.min>>>32));
        hash = 67*hash+Arrays.hashCode(this.cnt);
        return hash;
    }

    }
    HashSet<E> set=new HashSet<E>();
    private long func2(long min, int[] cnt) {
    if(cnt.length==1){
        return func3(min,cnt[0]);
    }
    E key = new E(min,cnt);
    if(set.contains(key))return INF;
    set.add(key);
    long res=INF;
    loop:for (int o = 0; o<10; o++) {
        int i=(int)((min+o)%10);
        int len = (i+cnt.length-1)/10 + 1;
        int[] ncnt=new int[len];
        fill(ncnt,-1);
        len=0;
        for (int j = 0; j<cnt.length; j++) {
        int tmp = cnt[j] - lucky((i+j)%10);
        if(tmp<0 || ncnt[len]!=-1 && ncnt[len]!=tmp)continue loop;
        ncnt[len]=tmp;
        if((i+j)%10==9)len++;
        }
        long tmp2=func2(min/10 + (i<min%10 ? 1:0), ncnt);
        res=min(tmp2*10+i,res);
    }
    return res;
    }

    private long func3(long min, int cnt) {
    long p10=1;
    int dig=1;
    while(p10<min || dig<cnt){
        p10*=10;
        dig++;
    }
    long res=0;
    while(dig>0){
        for (int i = 0;; i++) {
        long tmp = res + p10 * i;
        if(possible(tmp,min,p10/10,dig-1,cnt)){
            res=tmp;break;
        }
        if(i==9)throw new RuntimeException();
        }
        p10/=10;
        dig--;
    }
    return res;
    }

    private boolean possible(long tmp, long min,long p10, int dig, int cnt) {
    if(lucky(tmp) > cnt)return false;
    cnt -= lucky(tmp);
    if(cnt>dig)return false;
    while(cnt<dig){
        tmp += p10*9;
        dig--;
        p10/=10;
    }
    while(dig>0){
        tmp += p10*7;
        dig--;
        p10/=10;
    }
    return tmp>=min;
    }
}


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

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

class TaskE {

	long[][][][] dp;
	int MOD=1000000007;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
		int n=in.readInt(), k=in.readInt();
		dp=new long[n+1][k+1][n+1][2];
		ArrayUtils.fill(dp, -1);
		long[] factorial=IntegerUtils.generateFactorial(n, MOD), powers=IntegerUtils.generatePowers(2, n, MOD), reverse=new long[n];
		for (int i=0; i<n; i++) reverse[i]=IntegerUtils.reverse(powers[i], MOD);
		long ret=0;
		for (int i=1; i<=n; i++) {
			long x=0;
			for (int j=0; j<2; j++) x+=MiscUtils.max(dp[n][k][i][j], 0L);
			ret=(ret+x%MOD*factorial[n-1]%MOD*reverse[n-i]%MOD)%MOD;
		}
		out.printLine(ret);
    }

}

class InputReader {

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

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

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

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

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

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

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

class OutputWriter {
	private final PrintWriter writer;

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

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

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

}

class ArrayUtils {

	public static void fill(long[][] array, long value) {
		for (long[] row : array)
			Arrays.fill(row, value);
	}

	public static void fill(long[][][] array, long value) {
		for (long[][] row : array)
			fill(row, value);
	}

	public static void fill(long[][][][] array, long value) {
		for (long[][][] row : array)
			fill(row, value);
	}

}

class IntegerUtils {

	public static long power(long base, long exponent, long mod) {
		if (base >= mod)
			base %= mod;
		if (exponent == 0)
			return 1 % mod;
		long result = power(base, exponent >> 1, mod);
		result = result * result % mod;
		if ((exponent & 1) != 0)
			result = result * base % mod;
		return result;
	}

	public static long[] generateFactorial(int count, long module) {
		long[] result = new long[count];
		if (module == -1) {
			if (count != 0)
				result[0] = 1;
			for (int i = 1; i < count; i++)
				result[i] = result[i - 1] * i;
		} else {
			if (count != 0)
				result[0] = 1 % module;
			for (int i = 1; i < count; i++)
				result[i] = (result[i - 1] * i) % module;
		}
		return result;
	}

	public static long reverse(long number, long module) {
		return power(number, module - 2, module);
	}

	public static long[] generatePowers(long base, int count, long mod) {
		long[] result = new long[count];
		if (count != 0)
			result[0] = 1 % mod;
		for (int i = 1; i < count; i++)
			result[i] = result[i - 1] * base % mod;
		return result;
	}

}

class MiscUtils {

	public static<T extends Comparable<T>> T max(T first, T second) {
		if (first.compareTo(second) <= 0)
			return second;
		return first;
	}

}


//package cf589d2;
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class E {
	static long[][] choose = new long[270][270];
	static long MOD = 1000000007;
	public static void main(String[] args) {
		for(int i = 0; i < 270; i++) {
			choose[i][0] = 1;
			choose[i][i] = 1;
		}
		for(int i = 2; i < 270; i++)
			for(int j = 1; j < i; j++)
				choose[i][j] = choose[i - 1][j] + choose[i - 1][j - 1];
		MyScanner sc = new MyScanner();
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[][] dp = new long[n + 1][n + 1];
		dp[0][n] = 1;
		for(int i = 1; i <= n; i++)
			for(int j = 0; j <= n; j++)
				for(int l = 0; l <= j; l++) {
					long del;
					if(j > 0 && l < j)
						del = dp[i - 1][j] * choose[j][l] % MOD * pMod(k - 1, l) % MOD * pMod(k, n - j) % MOD;
					else if(j > 0)
						del = dp[i - 1][j] * choose[j][l] % MOD * pMod(k - 1, l) % MOD * (pMod(k, n - j) - 1) % MOD;
					else
						del = dp[i - 1][j] * (pMod(k, n) - pMod(k - 1, n)) % MOD;
					//System.out.println(i + " " + j + "  " + l + " { " + del);
					dp[i][l] = (dp[i][l] + del) % MOD;
				}

		out.println(dp[n][0]);
		out.close();
	}
	public static long pMod(long x, long p) {
		if(p == 0)
			return 1;
		long l = pMod(x, p / 2);
		return l * l % MOD * (p % 2 == 1 ? x : 1) % MOD;
	}
	public static PrintWriter out  = new PrintWriter(new BufferedOutputStream(System.out));
	public static class MyScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		String next() {
			while (st == null || !st.hasMoreElements())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


import java.util.*;

public class Sol{
    public static void main(String[] argc){
        Scanner sc = new Scanner(System.in);
        int n, k;
        String s;
        n = sc.nextInt();
        k = sc.nextInt();
        s = sc.next();

        boolean found = false;
        for (int i = 0; i < n; ++i) {
            int st = i;
            int en = i + k - 1;
            if (st -1 >=0 and s[st-1] == 'N') {
                continue;
            }
            if (en +1 <n and s[en +1] == 'N') {
                continue;
            }
            if (en >= n) {
                break;
            }

            boolean ok = true;
            for (int j = st; j <= en; ++j) {
                if (s.charAt(j) == 'Y') {
                    ok = false;
                }
            }
            if (ok) {
                found = true;
                break;
            }
        }

        int maxn = 0;

        for (int i = 0; i < n; ++i) {
            if (s.charAt(i) != 'N') {
                continue;
            }
            int cnt = 1;
            int j = i + 1;
            while (j < n && s.charAt(j) == 'N') {
                ++cnt;
                ++j;
            }

            if (cnt > maxn) {
                maxn = cnt;
            }
        }

        if (found && maxn <= k) {
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;

public class ProblemE {
	static int N;
	static long Y;
	static long ycnt;
	static int[] place;
	static boolean[][] invalid;
	static boolean[][] invalidGraph;
	static boolean[][] rules;

	private static long cnt(int now) {
		long[][] dp = new long[N+1][1<<N];
		int fptn = 0;
		for (int i = 0 ; i < N ; i++) {
			if (place[i] != -1) {
				fptn |= 1<<i;
			}
		}

		dp[now][fptn] = 1;
		for (int i = now ; i < N ; i++) {
			for (int ptn = 0 ; ptn < (1<<N) ; ptn++) {
				if (dp[i][ptn] <= 0) {
					continue;
				}
				for (int next = 0 ; next < N ; next++) {
					if ((ptn & (1<<next)) >= 1) {
						continue;
					}
					if (invalid[ptn][next]) {
						continue;
					}
					int nptn = ptn | (1<<next);
					dp[i+1][nptn] += dp[i][ptn];
				}
			}
		}
		return dp[N][(1<<N)-1];
	}

	private static void dfs(int now) {
		for (int i = 0 ; i < N ; i++) {
			if (place[i] == -1) {
				place[i] = now;
				if (now >= 1) {
					boolean isok = true;
					for (int j = 0 ; j < N ; j++) {
						if (place[j] == now - 1) {
							if (invalidGraph[j][i]) {
								isok = false;
								break;
							}
						}
					}
					if (!isok) {
						place[i] = -1;
						continue;
					}
				}

				long dcnt = cnt(now+1);
				if (ycnt + dcnt >= Y) {
					dfs(now+1);
					break;
				}
				ycnt += dcnt;
				place[i] = -1;
			}
		}
	}

	public static void main(String[] args) throws IOException {
		BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
		String[] line = s.readLine().split(" ");
		int n = Integer.valueOf(line[0]);
		long y = Long.valueOf(line[1]) - 2000;
		int m = Integer.valueOf(line[2]);

		invalid = new boolean[1<<n][n];
		invalidGraph = new boolean[n][n];
		for (int i = 0 ; i < m ; i++) {
			String[] data = s.readLine().split(" ");
			int senior = Integer.valueOf(data[0])-1;
			int junior = Integer.valueOf(data[1])-1;
			invalidGraph[junior][senior] = true;
			for (int j = 0 ; j < (1<<n) ; j++) {
				if ((j & (1<<junior)) >= 1) {
					invalid[j][senior] = true;
				}
			}
		}

		N = n;
		Y = y;
		ycnt = 0;
		place = new int[N];
		Arrays.fill(place, -1);

		dfs(0);

		if (place[0] == -1) {
			System.out.println("The times have changed");
			return;
		} else {
			int[] map = new int[N];
			for (int i = 0 ; i < n ; i++) {
				map[place[i]] = i;
			}

			StringBuffer b = new StringBuffer();
			for (int i = 0 ; i < n ; i++) {
				b.append(map[i]+1).append(" ");
			}
			System.out.println(b.substring(0, b.length()-1));
		}
	}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class D {

	private static StringTokenizer tokenizer;
    private static BufferedReader bf;
    private static PrintWriter out;

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

    @SuppressWarnings("unused")
	private static long nextLong() throws IOException {
    	return Long.parseLong(nextToken());
    }

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

	public static void main(String[] args) throws IOException {
		bf = new BufferedReader(new InputStreamReader(System.in));
    	tokenizer = null;
    	out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    	int b = nextInt(); int d = nextInt();
    	String a = nextToken(); String c = nextToken();
    	int inda = 0, indc = 0;
    	int lena = a.length();
    	int lenc = c.length();
    	long max = lena*b;
    	while(inda < max) {
    		if(c.charAt(indc%lenc) != a.charAt(inda%lena))
    			inda++;
    		else {
    			inda++; indc++;
    		}
    		if(indc%lenc == 0 && inda%lena == 0) break;
    	}
    	out.println((indc*max)/(lenc*d*inda));
    	out.close();
	}

}


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

public class B {
    private static class Cup implements Comparable<Cup> {
        public int price;
        public int weight;

        Cup(int price, int weight) {
            this.price = price;
            this.weight = weight;
        }

        @Override
        public int compareTo(Cup other) {
            if (this.price == other.price) {
                return this.weight - other.weight;
            }
            return other.price - this.price;
        }
    }
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int d = in.nextInt();

        Cup a[] = new Cup[n];
        Cup b[] = new Cup[m];

        for (int i = 0; i < n; ++i) {
            int c = in.nextInt();
            int w = in.nextInt();
            a[i] = new Cup(c, w);
        }

        for (int i = 0; i < m; ++i) {
            int c = in.nextInt();
            int w = in.nextInt();
            b[i] = new Cup(c, w);
        }
        Arrays.sort(a);
        Arrays.sort(b);

        long mp = 0;

        long cw = 0;
        long cp = 0;

        int mi = -1;
        for (int i = 0; i < n; ++i) {
            if (cw + a[i].weight <= d) {
                cw += a[i].weight;
                cp += a[i].price;
                mi = i;
            } else {
                break;
            }
        }

        int j = 0;
        while (mi >= 0) {
            while (j < m && cw + b[j].weight <= d) {
                cw += b[j].weight;
                cp += b[j].price;
                ++j;
            }
            if (j > 0) {
                mp = Math.max(mp, cp);
            }
            cp -= a[mi].price;
            cw -= a[mi].weight;
            --mi;
        }
        System.out.println(mp);
    }
}


// import org.junit.Test;
import java.util.Scanner;

// import static org.junit.Assert.assertEquals;

public class CF_1223G {
    static Scanner scanner = new Scanner(System.in);
    public static void main(String args[])
    {
         //test();
        long caseNum = 1;
        while (caseNum-- > 0) {
            task();
        }
    }

    private static int maxN = 500000;
    private static int[] a = new int[maxN + 10];
    private static int[] sum = new int[maxN + 10];
    private static int[] input = new int[maxN + 10];

    public static void task() {
        int n = scanner.nextInt();
        // System.out.println(n);
        for (int i = 0; i < n; i++) {
            input[i] = scanner.nextInt();
        }
        // System.out.println("input end");
        solve(n, input);
    }

    public static void clear(int n) {
        for (int i = 1; i <= maxN + 1; i++) {
            a[i] = 0;
            sum[i] = 0;
        }
    }

    private static int maxA;

    public static long solve(int n, int[] input) {
        long maxArea = 0;
        maxA = 0;
        clear(n);
        for (int i = 0; i < n; i++) {
            a[input[i]]++;
            if (input[i] > maxA) {
                maxA = input[i];
            }
        }
        for (int i = 2; i <= maxN + 1; i++) {
            sum[i] = a[i] + sum[i - 1];
        }

        for (int y = 2; y <= maxA; y++) {
            long total = 0;
            for (int step = y; step <= maxA; step += y) {
                total += q(step, min(step + y - 1, maxA) + 1) * (long) (step / y);
            }
            int x = 1;
            int left = 2;
            int right = maxA;
            while (left <= right) {
                int mid = (left + right) / 2;
                if (check(y, mid, total)) {
                    if (mid > x) {
                        x = mid;
                    }
                    left = mid + 1;
                } else {
                    right = mid - 1;
                }
            }
            if (x > 1) {
                if ((long) x * (long) y > maxArea) {
                    maxArea = (long) x * (long) y;
                    /*
                    System.out.println(y + " " + x);
                    System.out.println(maxArea);
                     */
                }
            }
        }
        System.out.println(maxArea);

        return maxArea;
    }

    public static boolean check(int y, int x, long total) {
        if (y == 4) {
           // System.out.println("fcuk");
        }
        boolean ret = check1(y, x, total, x + x, false) || check2(y, x, total);
        //System.out.println(y + " " + x + " " + total + " " + ret);
        return ret;
    }

    public static boolean check1(int y, int x, long total, int need, boolean ignore) {
        // together
        long up = (need - 1) / y + 1;
        long down = need / y;
        int hits = 0;
        if (!ignore) {
            if (need < y) {
                if (q(need, y) > 0) {
                    hits = 1;
                }
            }
        }
        if (hits == 1) {
            return total >= x;
        }
        int toSub = 0;
        int remain = need % y;
        for (int step = max(y, need - remain); step + remain <= maxA; step += y) {
            if (q(step + remain, min(step + y,maxA + 1)) > 0) {
                toSub = 1;
                break;
            }
        }
        if (toSub == 1) {
            return total >= x + down;
        } else {
            if (q(need, maxA + 1) > 0) {
                return total >= x + up;
            } else {
                return false;
            }
        }
    }

    private static int min(int x, int y) {
        if (x < y) {
            return x;
        }
        return y;
    }

    private static int max(int x, int y) {
        if (x > y) {
            return x;
        }
        return y;
    }

    public static boolean check2(int y, int x, long total) {
        // separate
        int need = x;
        int up = (need - 1) / y + 1;
        int down = need / y;
        int hits = 0;
        if (need < y) {
            if (q(need, y) > 0) {
                hits = q(need, y);
            }
            if (hits >= 2) {
                hits = 2;
            }
        }
        if (hits == 2) {
            return total >= x;
        }
        // ?
        if (hits == 1) {
            return check1(y, x, total, x, true);
        }
        if (q(need, maxA + 1) < 2){
            return false;
        }
        if (hits == 0) {
            int toSub = 0;
            int remain = need % y;
            for (int step = max(y, need - remain); step + remain <= maxA; step += y) {
                int h = q(step + remain, min(step + y,maxA + 1));
                toSub += h;
                if (toSub >= 2) {
                    toSub = 2;
                    break;
                }
            }
            if (toSub == 2) {
                return total >= x + down + down;
            }
            if (toSub == 1) {
                return total >= x + down + up;
            }
            if (toSub == 0) {
                return total >= x + up + up;
            }
        }
        // never
        return false;
    }

    public static int q(int begin, int end) {
        if (begin > end) {
            return 0;
        }
        return sum[end - 1] - sum[begin - 1];
    }

    public static void test() {
        int n = 90792;
        int[] input = new int[maxN + 10];
        input[0] = 181565;
        input[1] = 181564;
        for (int i = 2; i < n; i++) {
            input[i] = 60522;
        }
        System.out.println(solve(n, input));
    }

    /*
    @Test
    public void test() {
        int n = 1;
        int[] input = {9};
        assertEquals(4, solve(n, input));
    }

    @Test
    public void test2() {
        String s = "9\n" +
                "9 10 9 18 9 9 9 28 9";
        s = "9\n" +
                "9 10 9 19 9 9 9 28 9";
        Scanner scanner = new Scanner(s);
        int n = scanner.nextInt();
        int [] input = new int[500000 +100];
        for (int i = 0; i < n; i++) {
            input[i] = scanner.nextInt();
        }
        assertEquals(90, solve(n, input));
    }
     */
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeSet;
/*
5
4 1 1 1 3 3 3 3 1
4 4 3 6 2 6 0 4 0
6 -5 3 -4 4 -3 4 -2 3 -3 2 -4 2
3 0 -1 1 -3 -1 -3
4 1 -4 1 -6 -1 -6 -1 -4
5
8 1 1 1 2 1 3 2 3 3 3 3 2 3 1 2 1
4 4 3 6 2 6 0 4 0
6 -5 3 -4 4 -3 4 -2 3 -3 2 -4 2
3 0 -1 1 -3 -1 -3
4 1 -4 1 -6 -1 -6 -1 -4
7
4
1 0
1 1
2 1
2 0
4
4 -1
4 0
5 0
5 -1
4
7 0
7 1
8 1
8 0
4
10 -1
10 0
11 0
11 -1
4
-1 0
-1 -1
-2 -1
-2 0
4
-4 1
-4 0
-5 0
-5 1
4
-7 0
-7 -1
-8 -1
-8 0
 */
public class Geom {

	static int N, totalSz;
	static Poly ar[];
	static boolean RADIAL_SORT,ID_SORT;
	static Vec radialPnts[];
	static TreeSet<Poly> ts;
	static boolean inTreeSet[];
	static final boolean debug = false;
	static Vec ORIGIN = new Vec(0,0);
	static final double eps = 1e-6;

	public static void main(String args[]) {
		FS in = new FS();
		N = in.nextInt();
		ar = new Poly[N];
		//Read in the input and make the polygons
		for(int i = 0; i < N; i++) {
			int sz = in.nextInt();
			Vec pts[] = new Vec[sz];
			for(int j = 0; j < sz; j++) {
				double x = in.nextInt();
				double y = in.nextInt();
				int id = sz-j-1; //make counter-clockwise
				pts[id] = new Vec(x,y,id);
			}
			ar[i] = new Poly(pts, i);
			totalSz += ar[i].sz;
		}
		radialPnts = new Vec[totalSz];
		int idd = 0;
		for(Poly p : ar)
			for(Vec v : p.vs)
				radialPnts[idd++] = v;
		setRadialSort();
		Arrays.sort(radialPnts);
		initSweep();
		sweep();
		double res = 0;
		for(Poly p : ar)
			res += p.area();
		System.out.println(res);
	}

	static void sweep() {
		for(Vec v : radialPnts) {
			if(debug) {
				System.out.println("V= "+v);
				System.out.print("TS:");
				for(Poly p : ts) System.out.print(p.id+" ");
				System.out.println();
			}
			if(v.isLast) {
				//Removing this polygon
				Poly first = ts.first();
				ts.remove(v.poly);
				inTreeSet[v.poly.id] = false;
				if(first.id == v.poly.id && ts.size() > 0 ) { // If this polygon was first, add the lines to the next guy
					Poly next = ts.first();
					Seg s = new Seg(ORIGIN, v);
					next.intersectF(s, true);
					next.intersectR(s, true);
					next.isSeen = true; // This guy is seen
				}
				v.poly.killSegs();
			}
			else {
				v.poly.updateSegs(v);
				if(!inTreeSet[v.poly.id]) {
					Poly curFirst = ts.size() == 0 ? null : ts.first();
					ts.add(v.poly);
					inTreeSet[v.poly.id] = true;
					if(ts.first().id == v.poly.id) {
						v.poly.isSeen = true;
						if(curFirst != null) {
							Seg s = new Seg(ORIGIN, v);
							curFirst.intersectF(s, false);
							curFirst.intersectR(s, false);
						}
					}
				}
			}
		}
	}
	static void initSweep() {
		//Set up the fSegs and rSegs (but NOT isSeen / adding the lines/points);
		inTreeSet = new boolean[N];
		ts = new TreeSet<Poly>();
		for(Vec v : radialPnts) {
			if(debug) System.out.println("V= "+v);
			if(v.isLast) { //Remove this polygon
				ts.remove(v.poly);
				inTreeSet[v.poly.id] = false;
				v.poly.killSegs();
			}
			else {
				v.poly.updateSegs(v);
				if(!inTreeSet[v.poly.id]) ts.add(v.poly);
				inTreeSet[v.poly.id] = true;
			}
			if(debug) {
				System.out.print("TS:");
				for(Poly p : ts) System.out.print(p.id+" ");
				System.out.println();
			}
		}

		//Sweep is done, set the poly in the first of the treeset to be seen if there is one
		if(ts.size() > 0) {
			Poly first = ts.first();
			first.isSeen = true;
		}
		if(debug) System.out.println("Done with init\n\n\n");
	}

	static void setRadialSort() {
		RADIAL_SORT = true; ID_SORT = false;
	}
	static void setIDSort() {
		RADIAL_SORT = false; ID_SORT = true;
	}

	static class Vec implements Comparable<Vec>{
		double x,y;
		int id;
		double sId;
		Vec prev,next;
		Poly poly;
		boolean isLast;
		int polyRemoveId;

		public Vec(double xx, double yy) {x=xx;y=yy;}
		public Vec(double xx, double yy, int ii) {x=xx;y=yy;id=ii;sId=ii;}
		public double cross(Vec o) { return x*o.y - y*o.x; }
		public Vec add(Vec o) { return new Vec(x+o.x, y+o.y); }
		public Vec sub(Vec o) { return new Vec(x-o.x, y-o.y); }
		public double mag(Vec o) { return x*o.x + y*o.y; }
		public Vec scale(double d) { return new Vec(x*d,y*d);}

		public boolean inFrontOf(Seg o) {
			long c1 = (long)Math.round(o.a.cross(this));
			long c2 = (long)Math.round(this.cross(o.b));
			if(c1 >= 0 && c2 >= 0) {
				long c3 = (long)Math.round(o.dir.cross(this.sub(o.a)));
				return c3 >= 0;
			}
			return false;
		}

		public static int compare(Vec a, Vec b) {
			int res = 0;
			if(a.x < 0) res += a.y >= 0 ? 1 : 2;
			else if(a.y < 0) res += 3;
			if(b.x < 0) res -= b.y >= 0 ? 1 : 2;
			else if(b.y < 0) res -= 3;
			if(res == 0) {
				long cross = (long)Math.round(a.cross(b));
				//Further points come first if same angle
				if(cross == 0) return Long.compare((long)Math.round(b.mag(b)), (long)Math.round(a.mag(a)));
				if(cross > 0) return -1;
				else return 1;
			}
			return res;
		}

		@Override
		public int compareTo(Vec o) {
			if(RADIAL_SORT) {
				return Vec.compare(this, o);
			}
			else if(ID_SORT) {
				return Double.compare(sId, o.sId);
			}
			throw null;
		}
		@Override
		public String toString() {
			return "("+x+","+y+") id="+id+" p="+(poly == null ? -1 : poly.id)+" sId= "+sId;
		}
	}

	static class Seg{
		Vec a,b,dir;
		public Seg(Vec aa, Vec bb) {
			a=aa;
			b=bb;
			dir = b.sub(a);
		}

		public boolean inFrontOf(Seg o) {
			if(a.inFrontOf(o)) return true;
			if(b.inFrontOf(o)) return true;
			return false;
		}

		public Vec lineIntersect(Seg o) {
			double det = o.dir.x*dir.y-dir.x*o.dir.y;
			if(eq(det, 0)) return null;
			double dist = (o.dir.x * (o.a.y-a.y)-
					o.dir.y*(o.a.x-a.x))/det;
			return a.add(dir.scale(dist));
		}
	}
	static class Poly implements Comparable<Poly>{
		int sz, id;
		Vec vs[];
		Seg fSeg, rSeg;
		double fSegAId,rSegAId;
		boolean isSeen;
		ArrayList<Vec> interVecs;

		public Poly(Vec[] vss, int ii) {
			ArrayList<Vec> vs2 = new ArrayList<Vec>();
			for(int i = 0; i < vss.length; i++) {
				Vec v = vss[i];
				Vec prev = vss[(i-1+vss.length)%vss.length];
				Vec next = vss[(i+1)%vss.length];
				if((long)Math.round((v.sub(prev)).cross((next.sub(v)))) != 0) vs2.add(v);
			}
			vs = new Vec[vs2.size()];
			for(int i = 0; i < vs2.size(); i++) {
				Vec v = vs2.get(i);
				v.id = i; v.sId = i;
				vs[i] = v;
			}
			if(debug) {
				System.out.println("Poly: ");
				for(Vec v : vs) System.out.println("  v="+v);
			}

//			vs=vss;
			sz = vs.length;
			isSeen = false;
			id = ii;
			for(int i = 0; i < sz; i++) {
				Vec prev = vs[(i-1+sz)%sz];
				Vec next = vs[(i+1)%sz];
				vs[i].prev = prev;
				vs[i].next = next;
				vs[i].poly = this;
				long c1 = (long)Math.round(prev.cross(vs[i]));
				long c2 = (long)Math.round(next.cross(vs[i]));
				if(c1 >= 0 && c2 > 0) vs[i].isLast = true;
			}
			interVecs = new ArrayList<Vec>();
		}

		public void killSegs() { fSeg = null; rSeg = null; }
		public void updateSegs(Vec v) {
			if(fSeg == null || rSeg == null) {
				fSeg = new Seg(v, v.prev);
				fSegAId = v.id;
				rSeg = new Seg(v, v.next);
				rSegAId = v.id;
			}
			else {
				if(fSeg.b.id == v.id) {
					fSeg = new Seg(v, v.prev);
					fSegAId = v.id;
				}
				if(rSeg.b.id == v.id) {
					rSeg = new Seg(v, v.next);
					rSegAId = v.id;
				}
			}
		}
		public void intersectF(Seg s, boolean polyRemoved) {
			if(debug) System.out.println(" inter from "+s.b.poly.id +" to "+this.id);
			Vec v = s.lineIntersect(fSeg);
			//get the id for where to put this
			if(fSeg.b.id == sz-1 && eq(fSegAId, 0)) { //can't do inbetween because this is going from (sz-1) -> 0
				double d = fSegAId + (double)sz - eps;
				v.sId = d;
			}
			else {
				double d = fSegAId - eps;
				v.sId = d;
			}
			v.polyRemoveId = (polyRemoved ? 1 : -1);
			interVecs.add(v);
			fSegAId = v.sId;
		}
		public void intersectR(Seg s, boolean polyRemoved) {
			Vec v = s.lineIntersect(rSeg);
			//get hte id for where to put this
			if(rSeg.a.id == sz-1) {
				double d = rSegAId + eps;
				v.sId = d;
			}
			else {
				double d = rSegAId + eps;
				v.sId = d;
			}
			v.polyRemoveId = (polyRemoved ? 1 : -1);
			interVecs.add(v);
			rSegAId = v.sId;
		}

		public double area() {
			if(debug) System.out.println("PID: "+id+" seen="+isSeen);
			if(!isSeen) return 0;
			else {
				double res = 0;
				setIDSort();

				if(interVecs.size() == 0) return getArea(vs);

				Vec ps[] = new Vec[vs.length + interVecs.size()];
				int idd = 0;
				for(Vec v : vs) ps[idd++] = v;
				for(Vec v : interVecs) ps[idd++] = v;
				Arrays.sort(ps);

				if(debug) {
					System.out.println("Poly: "+id);
					for(Vec v : ps) System.out.println("  "+v);
					System.out.println();
				}

				int curL = ps.length-1, curR = 0;
				TreeSet<Vec> pts = new TreeSet<Vec>();
				pts.add(ps[curL]); pts.add(ps[curR]);
				while(true) {
					while(ps[curL].polyRemoveId == 0) {
						if(curL == curR) break;
						curL = (curL - 1 + ps.length)%ps.length;
						pts.add(ps[curL]);
					}
					while(ps[curR].polyRemoveId == 0) {
						if(curL == curR) break;
						curR = (curR + 1)%ps.length;
						pts.add(ps[curR]);
					}
					if(ps[curL].polyRemoveId == -1) res += getArea(tsToArray(pts));
					pts.clear();
					if(curR == curL) break;
					pts.add(ps[curL]);
					pts.add(ps[curR]);
					curL = (curL - 1 + ps.length)%ps.length;
					curR = (curR + 1)%ps.length;
					pts.add(ps[curL]);
					pts.add(ps[curR]);
				}

				return res;
			}
		}

		@Override
		public int compareTo(Poly o) {
			if(id == o.id) return 0;
			if(fSeg.inFrontOf(o.fSeg)) return -1;
			return 1;
		}

	}
	static Vec[] tsToArray(TreeSet<Vec> tss){
		Vec res[] = new Vec[tss.size()];
		int idd = 0;
		for(Vec v : tss) res[idd++] = v;
		return res;
	}
	static double getArea(Vec[] vs) {
		if(debug) {
			System.out.println("AREA:");
			for(Vec v : vs) System.out.println(" "+v);
		}
		double res = 0;
		for(int i = 0; i < vs.length; i++) {
			Vec a = vs[i];
			Vec b = vs[(i+1)%vs.length];
			res += (b.x - a.x) * ((b.y + a.y)/2.0);
		}
		if(debug)System.out.println("  a="+Math.abs(res));
		return Math.abs(res);
	}

	static boolean eq(double a, double b) {
		return Math.abs(a-b) <= eps;
	}

	static class FS{
		BufferedReader br;
		StringTokenizer st;
		public FS() { br = new BufferedReader(new InputStreamReader(System.in));}
		String next() {
			while(st == null || !st.hasMoreElements()) {
				try { st = new StringTokenizer(br.readLine());}
				catch(Exception e) { throw null;}
			}
			return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next());}
	}
}


import java.util.Scanner;

public class E {
  static Scanner sc = new Scanner(System.in);
  static final double logE = Math.log(Math.E);

  public static void main(String[] args) {
    int V = sc.nextInt();
    double[] factLog = new double[3001];
    for (int i = 1; i < factLog.length; i++) {
      factLog[i] = Math.log(i) + factLog[i - 1];
    }
    for (int i = 0; i < V; i++) {
      int[] K = new int[250];
      long sum = 0;
      for (int j = 0; j < K.length; j++) {
        K[j] = sc.nextInt();
        sum += K[j];
      }
      double P = sum * 1.0 / K.length;
      double uniform = -Math.log(2 * P + 1) * K.length;
      double poisson = 0;
      for (int j = 0; j < K.length; j++) {
        poisson += K[j] * Math.log(P) - P * logE - factLog[K[j]];
      }
//      System.err.println(uniform + " " + poisson);
      int bestI = 0;
      if (uniform < poisson) {
        double bestLikelyhood = -Double.MAX_VALUE;
        for (int j = Math.max(10, (int) P - 10); j <= (int) P + 10; j++) {
          double likelyhood = 0;
          for (int k = 0; k < K.length; k++) {
            likelyhood += K[k] * Math.log(j) - j * logE;
          }
          if (likelyhood > bestLikelyhood) {
            bestLikelyhood = likelyhood;
            bestI = j;
          }
        }
      } else {
        bestI = (int) P;
      }
      System.out.println(bestI);
    }
  }

}


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 {

    final int MOD = 1000000007;

    void run() {
        String start = next();
        String end = next();
        int K = nextInt();
        int N = start.length();

        if (K == 0) {
            if (start.equals(end)) {
                System.out.println(1);
            } else {
                System.out.println(0);
            }

            return;
        }

        long[] dp = new long[N];
        Arrays.fill(dp, 1);
        dp[0] = 0;

        for (int i = 1; i < K; i++) {
            long sum = 0;
            for (int j = 0; j < N; j++) sum += dp[j];
            sum %= MOD;

            for (int j = 0; j < N; j++) dp[j] = (sum - dp[j] + MOD) % MOD;
        }

        long ans = 0;
        String s1, s2;
        for (int i = 0; i < N; i++) {
            s1 = start.substring(0, i);
            s2 = start.substring(i);

            if (end.equals(s2.concat(s1))) {
                ans += dp[i];
                if (ans >= MOD) ans -= MOD;
            }
        }

        System.out.println(ans);
    }

    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 com.sun.javafx.geom.Edge;

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

public class F {

	static final int INF = (int)1e9;
	static ArrayList<Integer>[] adjList;
	static int[][] res, cost;
	static int[] p;

	static void addEdge(int u, int v, int c, int w)
	{
		adjList[u].add(v);
		adjList[v].add(u);
		res[u][v] = c;
		cost[u][v] = w;
		cost[v][u] = -w;
	}

	static int augment(int v, int flow)
	{
		if(v == src)
			return flow;
		int u = p[v];
		flow = augment(u, Math.min(flow, res[u][v]));
		res[u][v] -= flow;
		res[v][u] += flow;
		totalCost += flow * cost[u][v];
		return flow;
	}

	static int totalCost;

	static int mcmf(int V)
	{
		totalCost = 0;

		while(true)
		{
			p = new int[V];
			Arrays.fill(p, -1);
			p[0] = 0;
			int[] dist = new int[V];
			Arrays.fill(dist, INF);
			boolean[] inQueue = new boolean[V];
			int[] cntIn = new int[V];

			dist[0] = 0;
			Queue<Integer> q = new LinkedList<>();
			q.add(0);
			inQueue[0] = true;
			while(!q.isEmpty())
			{
				int u = q.remove();
				for(int v: adjList[u])
					if(res[u][v] > 0 && dist[v] > dist[u] + cost[u][v])
					{
						dist[v] = dist[u] + cost[u][v];
						p[v] = u;
						if(!inQueue[v])
						{
							inQueue[v] = true;
							if(++cntIn[v] <= V)
								q.add(v);
						}
					}
			}

			if(p[sink] == -1)
				break;
			augment(sink, INF);
		}
		return totalCost;
	}

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int[] f = new int[26];
		for(char c: s)
			f[c - 'a']++;
		int[] beu = new int[n];
		int sum = 0;
		for(int i = 0; i < n; ++i)
			sum += beu[i] = sc.nextInt();

		int gateOffset = 2, nodeOffset = gateOffset + n / 2 * 26, charOffset = nodeOffset + n;
		int V = charOffset + 26;
		res = new int[V][V];
		cost = new int[V][V];
		adjList = new ArrayList[V];
		for(int i = 0; i < V; ++i)
			adjList[i] = new ArrayList<>(1);

		// Source and Sink
		src = 0; sink = 1;

		// Source -> Indices Nodes -> Limiter Gates
		for(int i = 0; i < n; ++i)
		{
			addEdge(src, nodeOffset + i, 1, 0);
			for(int c = 0; c < 26; ++c)
			{
				int x = i * 2 < n ? i : n - i - 1;
				int gateIn = gateOffset + n / 2 * c + x;
				addEdge(nodeOffset + i, gateIn, 1, s[i] - 'a' == c ? 0 : beu[i]);
			}
		}

		// Limiter Gates -> Characters -> Sink
		for(int c = 0; c < 26; ++c)
		{
			addEdge(charOffset + c, sink, f[c], 0);
			for(int gate = 0; gate < n / 2; ++gate)
				addEdge(gateOffset + n / 2 * c + gate, charOffset + c, 1, 0);
		}

		out.println(sum - mcmf(V));
		out.close();
	}

	static int src, sink;

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

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

		public Scanner(FileReader s) throws FileNotFoundException {	br = new BufferedReader(s);}

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

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

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

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

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

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


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;

public class F38 {

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

    static int nextInt() throws IOException {
        in.nextToken();
        return Integer.valueOf(in.sval);
    }

    static double nextDouble() throws IOException {
        in.nextToken();
        return Double.valueOf(in.sval);
    }

    static String nextString() throws IOException {
        in.nextToken();
        return in.sval;
    }

    static {
        in.ordinaryChars('0', '9');
        in.wordChars('0', '9');

        in.ordinaryChars('.', '.');
        in.wordChars('.', '.');

        in.ordinaryChars('-', '-');
        in.wordChars('-', '-');
    }

    public static void main(String[] args) throws IOException {
        n = nextInt();
        voc = new String[n];
        for (int i = 0; i < n; i++)
            voc[i] = nextString();

        h.put("", new Node(""));
        nodes.offer(h.get(""));

        for (int i = 0; i < n; i++)
            for (int j = 0; j < voc[i].length(); j++)
                for (int k = j+1; k <= voc[i].length(); k++) {
                    String cur = voc[i].substring(j, k);
                    if (!h.containsKey(cur)) {
                        h.put(cur, new Node(cur));
                        nodes.offer(h.get(cur));
                    }
                }

        for (Node node : nodes)
            for (int i = 0; i < n; i++)
                if (voc[i].indexOf(node.s) >= 0)
                    node.cnt++;

        for (Node node : nodes) {
            for (int i = 0; i < 26; i++) {
                String cur = (char)(i+'a') + node.s;
                if (h.containsKey(cur)) node.g.add(h.get(cur));
            }
            for (int i = 0; i < 26; i++) {
                String cur = node.s + (char)(i+'a');
                if (h.containsKey(cur)) node.g.add(h.get(cur));
            }
        }

        for (Node node : nodes)
            if (node.points == null)
                play(node);

        /*for (Node node : nodes) {
            out.println(node.s);
            out.print(node.cnt);
            out.print(" " + node.g.size());
            out.println(" " + node.value);
            out.println(node.points[0] + " " + node.points[1]);
            out.println();
        }*/

        Node ans = h.get("");
        out.println(ans.points[0] > ans.points[1] ? "First" : "Second");
        out.println(ans.points[0] + " " + ans.points[1]);

        out.flush();
    }

    static final int M = 30;
    static HashMap<String, Node> h = new HashMap<String, Node>(M*M*M);
    static int n;
    static String[] voc;
    static LinkedList<Node> nodes = new LinkedList<Node>();

    static void play(Node node) {
        for (Node go : node.g) {
            if (go.points == null) play(go);
            int a = go.points[1] + go.value + go.cnt, b = go.points[0];
            if (node.points == null) {
                node.points = new int[]{a, b};
            }
            else if (better(a, b, node.points[0], node.points[1])) {
                node.points[0] = a;
                node.points[1] = b;
            }
        }
        if (node.points == null) {
            node.points = new int[]{0, 0};
        }
    }

    static boolean better(int a1, int b1, int a2, int b2) {
        if (a2 > b2 && a1 < b1) return false;
        if (a2 > b2 && a1 > b1) return a1 > a2 || (a1 == a2 && b1 < b2);
        if (a2 < b2 && a1 < b1) return a1 > a2 || (a1 == a2 && b1 < b2);
        if (a2 < b2 && a1 > b1) return true;
        if (a2 == b2 && a1 > b1) return true;
        if (a2 == b2 && a1 < b1) return false;
        if (a2 > b2 && a1 == b1) return false;
        if (a2 < b2 && a1 == b1) return true;
        return a1 > a2;
    }
}

class Node {
    String s;
    int cnt = 0, value;
    HashSet<Node> g = new HashSet<Node>();
    int[] points;

    public Node(String s) {
        this.s = s;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < s.length(); i++) {
            int x = s.charAt(i) - 'a' + 1;
            value += x;
            max = Math.max(max, x);
        }
        value *= max;
    }
}


//package Hackerearth;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Reducto
   {

	public static void main(String[] gud) throws IOException
	{
		BufferedReader br=new BufferedReader(newInputStreamReader(System.in));

		String s=br.readLine().trim();
		int m=(s.length()-1)/2 ;
		int a=(int)(s.charAt(m)-'0');
		if((a&1)==1)System.out.println("Yes");
		else System.out.println("No");
	  }

	public static class Rational implements Comparable<Rational> {
		BigInteger num;
		BigInteger den;

		public static final Rational ZERO = new Rational(0);
		public static final Rational ONE = new Rational(1);
		public static final Rational POSITIVE_INFINITY = new Rational(1, 0);
		public static final Rational NEGATIVE_INFINITY = new Rational(-1, 0);

		public Rational(long num) {
			this.num = BigInteger.valueOf(num);
			this.den = BigInteger.ONE;
		}

		public Rational(long num, long den) {
			this.num = BigInteger.valueOf(num);
			this.den = BigInteger.valueOf(den);
			reduce();
		}

		public Rational(BigInteger num, BigInteger den) {
			this.num = num;
			this.den = den;
			reduce();
		}

		void reduce() {
			BigInteger gcd = num.gcd(den);
			if (gcd.signum() != 0) {
				num = num.divide(gcd);
				den = den.divide(gcd);
			}
			if (den.signum() < 0) {
				num = num.negate();
				den = den.negate();
			}
		}

		public Rational add(Rational r) {
			return new Rational(num.multiply(r.den).add(r.num.multiply(den)),
					den.multiply(r.den));
		}

		public Rational sub(Rational r) {
			return new Rational(num.multiply(r.den).subtract(
					r.num.multiply(den)), den.multiply(r.den));
		}

		public Rational mul(Rational r) {
			return new Rational(num.multiply(r.num), den.multiply(r.den));
		}

		public Rational div(Rational r) {
			return new Rational(num.multiply(r.den), den.multiply(r.num));
		}

		public Rational negate() {
			return new Rational(num.negate(), den);
		}

		public Rational inverse() {
			return new Rational(den, num);
		}

		public Rational abs() {
			return new Rational(num.abs(), den);
		}

		public int signum() {
			return num.signum();
		}

		public double doubleValue() {
			return num.doubleValue() / den.doubleValue();
		}

		public int compareTo(Rational other) {
			return (num.multiply(other.den).compareTo(other.num.multiply(den)));
		}

		public boolean equals(Object obj) {
			return obj instanceof Rational && num.equals(((Rational) obj).num)
					&& den.equals(((Rational) obj).den);
		}

		public int hashCode() {
			return num.hashCode() * 31 + den.hashCode();
		}

		public String toString() {
			if (den.equals(BigInteger.ONE)) {
				return num.toString();
			}
			if (num.compareTo(den) < 0) {
				return num + "/" + den;
			}
			return num.divide(den) + " " + num.mod(den) + "/" + den;
		}
	}

}


//package school3;

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

public class F4 {
    Scanner in;
    PrintWriter out;
    //	String INPUT = "100000 3";
    //String INPUT = "100000 2";
    String INPUT = "";

    int[] dec(int n, int m)
    {
	if(n <= m){
	    return new int[]{n, 0};
	}else if(n <= 2 * m){
	    return new int[]{n - m, n - m};
	}else{
	    return new int[]{n - 2 * m - 1, m};
	}
    }

    int enc(int x, int y, int m)
    {
	if(y == 0){
	    return x;
	}else if(x == y){
	    return x + m;
	}else{
	    return x + 2 * m + 1;
	}
    }

    void solve()
    {
	int m = ni();
	int n = ni();
	if(n <= Math.sqrt(Math.sqrt(m))){
	    solveH(m, n);
	}else{
	    solveB(m, n);
	}
    }

    void solveB(int m, int n){
	// (a, 0), (a, a), (a, m)
	BitSet visitedo = new BitSet();
	BitSet visitedh = new BitSet();
	int[] stepo = new int[3 * m+1];
	int[] steph = new int[3 * m+1];
	Arrays.fill(stepo, -1);
	Arrays.fill(steph, -1);
	BitSet q = new BitSet();
	q.set(0);
	boolean iso = true;
	int step = 0;

	outer:
	while(!q.isEmpty()){
	    //				tr(step, q);
	    BitSet nq = new BitSet();
	    if(iso){
		visitedh.or(q);
	    }else{
		visitedo.or(q);
	    }
	    for(int cur = q.nextSetBit(0);cur != -1;cur = q.nextSetBit(cur+1)){
		if(!iso && cur == 2 * m)break outer;
		int[] co = dec(cur, m);
		if(iso){
		    {
			if(co[1] == 0){
			    int inf = co[0] + 1;
			    int sup = Math.min(m, co[0] + n);
			    if(inf <= sup){
				nq.set(enc(inf, 0, m), enc(sup, 0, m) + 1);
			    }
			}
		    }
		    {
			int inf = Math.max(co[0], co[1]);
			if(co[0] == co[1])inf++;
			int sup = Math.min(m, (n + co[0] + co[1]) / 2);

			if(inf <= sup){
			    nq.set(enc(inf, inf, m), enc(sup, sup, m) + 1);
			}
		    }
		    {
			int inf = co[0];
			if(co[1] == m)inf++;
			int sup = Math.min(m - 1, co[0] + n - m + co[1]);
			if(inf <= sup){
			    nq.set(enc(inf, m, m), enc(sup, m, m) + 1);
			}
		    }
		}else{
		    {
			if(co[1] == m){
			    int inf = co[0] - 1;
			    int sup = Math.max(0, co[0] - n);
			    if(sup <= inf){
				nq.set(enc(sup, m, m), enc(inf, m, m) + 1);
			    }
			}
		    }
		    {
			int inf = Math.min(co[0], co[1]);
			if(co[0] == co[1])inf--;
			int sup = Math.max(0, (-n + co[0] + co[1]) / 2);

			if(sup == 0)sup++;
			if(sup <= inf){
			    nq.set(enc(sup, sup, m), enc(inf, inf, m) + 1);
			}
		    }
		    {
			int inf = co[0];
			if(co[1] == 0)inf--;
			int sup = Math.max(0, co[0] - n + co[1]);
			if(sup <= inf){
			    nq.set(enc(sup, 0, m), enc(inf, 0, m) + 1);
			}
		    }
		}
	    }
	    if(iso){
		nq.andNot(visitedo);
		for(int i = nq.nextSetBit(0);i != -1;i = nq.nextSetBit(i+1)){
		    int[] z = dec(i, m);
		    if(steph[enc(m - z[0], m - z[1], m)] >= 0){
			out.println(2 * step + 1);
			return;
		    }
		    stepo[i] = step;
		}
	    }else{
		nq.andNot(visitedh);
		for(int i = nq.nextSetBit(0);i != -1;i = nq.nextSetBit(i+1)){
		    int[] z = dec(i, m);
		    if(stepo[enc(m - z[0], m - z[1], m)] >= 0){
			out.println(2 * step + 1);
			assert false;
			return;
		    }
		    steph[i] = step;
		}
	    }
	    q = nq;
	    step++;
	    iso = !iso;
	}
	if(q.isEmpty()){
	    out.println(-1);
	}else{
	    //out.println(step);
	    //while(true);
	    //assert false;
	}
    }

    void solveH(int m, int n){

	// (a, 0), (a, a), (a, m)
	HashSet<Integer> visitedo = new HashSet<Integer>();
	HashSet<Integer> visitedh = new HashSet<Integer>();
	int[] stepo = new int[3 * m+1];
	int[] steph = new int[3 * m+1];
	Arrays.fill(stepo, -1);
	Arrays.fill(steph, -1);
	HashSet<Integer> q = new HashSet<Integer>();
	q.add(0);
	boolean iso = true;
	int step = 0;

	outer:
	while(!q.isEmpty()){
	    //			tr(step, q);
	    HashSet<Integer> nq = new HashSet<Integer>();
	    if(iso){
		visitedh.addAll(q);
	    }else{
		visitedo.addAll(q);
	    }
	    for(int cur : q){
		if(!iso && cur == 2 * m)break outer;
		int[] co = dec(cur, m);
		if(iso){
		    {
			if(co[1] == 0){
			    int inf = co[0] + 1;
			    int sup = Math.min(m, co[0] + n);
			    if(inf <= sup){
				for(int i = enc(inf, 0, m);i <= enc(sup, 0, m);i++){
				    nq.add(i);
				}
			    }
			}
		    }
		    {
			int inf = Math.max(co[0], co[1]);
			if(co[0] == co[1])inf++;
			int sup = Math.min(m, (n + co[0] + co[1]) / 2);

			if(inf <= sup){
			    for(int i = enc(inf, inf, m);i <= enc(sup, sup, m);i++){
				nq.add(i);
			    }
			}
		    }
		    {
			int inf = co[0];
			if(co[1] == m)inf++;
			int sup = Math.min(m - 1, co[0] + n - m + co[1]);
			if(inf <= sup){
			    for(int i = enc(inf, m, m);i <= enc(sup, m, m);i++){
				nq.add(i);
			    }
			}
		    }
		}else{
		    {
			if(co[1] == m){
			    int inf = co[0] - 1;
			    int sup = Math.max(0, co[0] - n);
			    if(sup <= inf){
				for(int i = enc(sup, m, m);i <= enc(inf, m, m);i++){
				    nq.add(i);
				}
			    }
			}
		    }
		    {
			int inf = Math.min(co[0], co[1]);
			if(co[0] == co[1])inf--;
			int sup = Math.max(0, (-n + co[0] + co[1]) / 2);

			if(sup == 0)sup++;
			if(sup <= inf){
			    for(int i = enc(sup, sup, m);i <= enc(inf, inf, m);i++){
				nq.add(i);
			    }
			}
		    }
		    {
			int inf = co[0];
			if(co[1] == 0)inf--;
			int sup = Math.max(0, co[0] - n + co[1]);
			if(sup <= inf){
			    for(int i = enc(sup, 0, m);i <= enc(inf, 0, m);i++){
				nq.add(i);
			    }
			}
		    }
		}
	    }
	    if(iso){
		nq.removeAll(visitedo);
		for(int i : nq){
		    int[] z = dec(i, m);
		    if(steph[enc(m - z[0], m - z[1], m)] >= 0){
			out.println(2 * step + 1);
			return;
		    }
		    stepo[i] = step;
		}
	    }else{
		nq.removeAll(visitedh);
		for(int i : nq){
		    int[] z = dec(i, m);
		    if(stepo[enc(m - z[0], m - z[1], m)] >= 0){
			out.println(2 * step + 1);
			assert false;
			return;
		    }
		    steph[i] = step;
		}
	    }
	    q = nq;
	    step++;
	    iso = !iso;
	}
	if(q.isEmpty()){
	    out.println(-1);
	}else{
	    //out.println(step);
	    //while(true);
	    //assert false;
	}
    }

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

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

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

    int ni() { return Integer.parseInt(in.next()); }
    void tr(Object... o) { if(INPUT.length() != 0)System.out.println(o.length > 1 || o[0].getClass().isArray() ? Arrays.deepToString(o) : o[0]); }
}


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

public class Codechef {

    static class MyScanner{
        BufferedReader br;
	StringTokenizer st;

	MyScanner(FileReader fileReader){
            br = new BufferedReader(fileReader);
	}

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

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

	char nc(){
            return nn().charAt(0);
	}

	int ni(){
            return Integer.parseInt(nn());
	}

	long nl(){
            return Long.parseLong(nn());
	}

	double nd(){
            return Double.parseDouble(nn());
	}

	int[] niArr0(int n){
            int[] ar = new int[n];
            for(int i = 0; i < n; i++) ar[i] = ni();
            return ar;
	}

        int[] niArr1(int n){
            int[] ar = new int[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = ni();
            return ar;
	}

        long[] nlArr0(int n){
            long[] ar = new long[n];
            for(int i = 0; i < n; i++) ar[i] = nl();
            return ar;
        }

        long[] nlArr1(int n){
            long[] ar = new long[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = nl();
            return ar;
        }
    }

    public static <T> void mprintln(T ... ar){
        for(T i: ar) out.print(i + " ");
        out.println();
    }

    private static PrintWriter out;

    public static void main(String[] args) throws FileNotFoundException{

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    private static void getAns(MyScanner sc){
        int n = sc.ni(), m = sc.ni();
        int[] k = sc.niArr0(n);
        HashMap<Integer, ArrayList<Integer>> map = new HashMap();

        for(int i = 0; i < m; i++){
            int day = sc.ni();
            map.putIfAbsent(day, new ArrayList<>());
            map.get(day).add(sc.ni());
        }

        int start = 1, end = 2 * (int)1e5;
        int ans = end;

//        out.println(map);

        while(start <= end){
            int mid = start + (end - start) / 2;
            if(OK(mid, map, Arrays.copyOf(k, n), n)){
                ans = mid;
                end = mid - 1;
            }else{
                start = mid + 1;
            }
        }

        out.println(ans);
    }

    private static boolean OK(int days, HashMap<Integer, ArrayList<Integer>> map, int[] k, int n){
        int cur = 0;
//        out.println(days);

        for(int i = 1; i <= days; i++){
            ++cur;
            ArrayList<Integer> index = map.get(i);
            if(index == null) continue;
            for(Integer in: index){
                int min = Math.min(cur, k[in - 1]);
                cur -= min;
                k[in - 1] -= min;
            }
        }

        for(int i = 0; i < n; i++) cur -= 2 * k[i];

        return cur >= 0;
    }
}


import java.util.ArrayList;
import java.util.Scanner;
import java.lang.Integer;

public class FlowGraph {
	int[][] graph;
	int[][] flow;
	int[] path;
	int[][] capacity;
	int size;
	int maxFlow = 0;

	public FlowGraph(int[][] capacity){
		//Scanner scanner = new Scanner(System.in);
		size = capacity.length;
		flow = new int[size][size];
		graph= new int[size][size];
		this.capacity = capacity;

	}

	int edmundKarp(){
		path = new int[size];
		for(int i = 0; i < size;  i++){
			path[i] = -1;
		}
		while(hasPath()){
			int cMin = 200000;
			int v = size - 1;
			while(v != 0){
				int u = path[v];
				if(capacity[u][v] - flow[u][v] < cMin ) cMin = capacity[u][v] - flow[u][v];
				v = u;

			}
			v = size - 1;
			while(v != 0){
				int u = path[v];

				flow[u][v] += cMin;
				flow[v][u] -= cMin;
				v = u;

			}

		}
		int maxFlow = 0;
		for(int i = 0; i < size; ++i){
			maxFlow += flow[i][size - 1];

		}
		return maxFlow;

	}
	boolean hasPath(){
		boolean[] visited = new boolean[size];
		ArrayList<Integer> o = new ArrayList<>();
		o.add(0);
		visited[0] = true;
		int v = 0;
		while(!o.isEmpty() && v != size - 1){
			int u = o.remove(o.size()-1);
			for(int i = 0; i < size;++i){
				if(capacity[u][i] - flow[u][i] > 0 && !visited[i]){
					path[i] = u;
					visited[i] = true;
					o.add(0,i);
					v = i;
					if(v == size - 1) break;
				}

			}

		}
		if(o.isEmpty()) return false;
		return true;

	}

	int findMaxFlow(){
		for(int i = 1; i < size; ++i){
			maxFlow += flow[i][size - 1];
		}
		return maxFlow;

	}

}

public class Labs {

	static void paths(int[][]graph,int n){
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < n; ++j){
				if(graph[i][j] == 0 && i != j) graph[i][j] = 1000;

			}

		}

		for(int k = 0; k < n; ++k ){
			for(int i = 0; i < n; ++i){
				for(int j = 0; j < n; ++j){
					if(graph[i][k] + graph[k][j] < graph[i][j]) graph[i][j] = graph[i][k]+graph[k][j];
				}
			}
		}

	}

	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int t = scanner.nextInt();
		int[][] lab = new int[n*n][n*n];
		int[][] flow = new int[n*n+2][n*n+2];
		String[] map = new String[n];
		int z = -1;
		scanner.nextLine();
		ArrayList<Integer> caps= new ArrayList<>();
		for(int i = 0; i < n; ++i){
			map[i] = scanner.nextLine();

		}

		for(int i = 0; i <n; ++i){
			for(int j = 0; j < n ; ++j){
				if(map[i].charAt(j)  == 'Z' || map[i].charAt(j) <= '9' && map[i].charAt(j) >= 0){
					if(map[i].charAt(j) != 'Z') flow[0][i*n+j+1] =(int) map[i].charAt(j) - 48;
						if(map[i].charAt(j)  == 'Z' ) z = i*n + j;

						if(i > 0 && map[i-1].charAt(j) <= '9' && map[i-1].charAt(j) >= '0'){
							if(map[i].charAt(j)  != 'Z') lab[(i-1)*n+j][i*n+j] = 1;
							lab[i*n+j][(i-1)*n+j] = 1;
						}
						if(i < n - 1 && map[i+1].charAt(j) <= '9' && map[i+1].charAt(j) >= '0'){
							lab[i*n+j][(i+1)*n+j] = 1;
							if(map[i].charAt(j)  != 'Z') lab[(i+1)*n+j][i*n+j] = 1;
						}
						if(j > 0 && map[i].charAt(j-1) <= '9' && map[i].charAt(j-1) >= '0'){
							if(map[i].charAt(j)  != 'Z') lab[(i)*n+j - 1][i*n+j] = 1;
							 lab[i*n+j][(i)*n+j-1] = 1;
						}
						if(j < n-1 && map[i].charAt(j+1) <= '9' && map[i].charAt(j+1) >= '0'){
							if(map[i].charAt(j)  != 'Z') lab[(i)*n+j+1][i*n+j] = 1;
							lab[i*n+j][(i)*n+j+1] = 1;
						}
				}

			}

		}
		paths(lab,n*n);
		scanner.nextLine();
		for(int i =0; i < n; ++i){
			String s = scanner.nextLine();
			for(int j = 0; j < n ; ++j){
				if(s.charAt(j) <= '9' && s.charAt(j) >= '1'){
					caps.add(i*n+j);
					flow[i*n+j+1][n*n+1] = (int) s.charAt(j) - 48;

				}
			}
		}
		for(int i = 0; i < n*n; ++i){
			if(i!= z){
			for(int j = 0; j < caps.size(); ++j){
				int c = caps.get(j);
				boolean neigh = false;
				for(int k = 0; k < n*n; ++k){
					if(lab[c][k] == 1){
						if(lab[i][k] < lab[z][k] && lab[i][k] <= t) neigh = true;
					}
				}
				if(lab[i][c] <= t && (lab[i][c] < lab[z][c] || lab[z][c] == 0 || neigh)){
					flow[i+1][c+1] = 10000;
				}

			}
			}

		}
		FlowGraph g = new FlowGraph(flow);
		g.edmundKarp();
		System.out.println(g.findMaxFlow());

	}

}