import java.io.ObjectInputStream.GetField;
import java.util.Scanner;

public class Problem3 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner in = new Scanner(System.in);

		while (in.hasNextLine()) {
			   String line = in.nextLine();
			   String[] arguments = line.split(" ");
			   getPerfectPair(Long.parseLong(arguments[0]), Long.parseLong(arguments[1]), Long.parseLong(arguments[2]));
		}

	}

	private static void getPerfectPair(long primerNumero, long segundoNumero, long destino) {

		long res=0;

		if(stopConditionReachDestination(primerNumero, segundoNumero, destino)) {
			res=0;
			System.out.println(res);
		}
		else if(stopConditionNeverReach(primerNumero, segundoNumero, destino)) {
			res=-1;
			System.out.println(res);
		}
		if(primerNumero>segundoNumero) {
			long aux = primerNumero;
			primerNumero = segundoNumero;
			segundoNumero =aux;
		}
		else {
			while(!stopConditionReachDestination(primerNumero, segundoNumero, destino)) {

					long aux = primerNumero;
					primerNumero=segundoNumero;
					segundoNumero+=aux;
				}
				res++;
			}

			System.out.println(res);
		}

	}

	private static boolean stopConditionNeverReach(long a, long b, long c) {

		return a<=0 && b<=0;
	}

	private static boolean stopConditionReachDestination(long a, long b, long c) {
		return a >=c || b>=c;
	}

}


import java.io.*;
import java.util.*;
/*
 * https://codeforces.com/contest/1191/problem/A
 */
public class Main {

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        PrintWriter wr = new PrintWriter(System.out);

        int hp = Integer.parseInt(br.readLine().trim());

        Map<Integer, Integer> category = new HashMap<>();

        category.put(0, 4);
        category.put(1, 1);
        category.put(2, 3);
        category.put(3, 2);

        int rem = hp % 4;

        for (int i = 0; i <= 2; i++) {
            int new_rem = (hp+ 1 ) % 4;
            if (category.get(rem) > category(new_rem)) {
                rem = new_rem;
            }
        }

        if (rem == 0) {
            out.println(rem + " " + 'D');
        } else if (rem == 1) {
            out.println(rem + " " + 'A');
        } else if (rem == 2) {
            out.println(rem + " " + 'C');
        } else if (rem == 3) {
            out.println(rem + " " + 'B');
        }

        wr.close();

        br.close();

    }

}


import java.util.*;

public class TriGun2{
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();

		System.out.println(max(n-a, b+1));
	}

	public int max(int a, int b){
		if(a>b)
			return a;
		else
			return b;
	}

}


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

public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        boolean unimodal = true;
        boolean inc = false, mode = false, dec = false;
        boolean preinc = false, premode = false, predec = false;

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

        (if n > 1)
        {
            if (a[1] > a[0])
                inc = true;
            else if (a[1] == a[0])
                mode = true;
            else
                dec = true;
        }

        for (int i = 2; i < n; i++)
        {
            preinc = inc;
            premode = mode;
            predec = dec;

            inc = (a[i] > a[i - 1]);
            mode = (a[i] == a[i - 1]);
            dec = (a[i] < a[i - 1]);

            if ((predec && mode) || (predec && inc) || (premode && inc))
            {
                unimodal = false;
                break;
            }

        }

        if (unimodal)
            System.out.println("YES");
        else
            System.out.println("NO");

    }
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
    final static long MOD = 1000000007;
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        String s = fs.nextLine();
        if(s.contains("H") || s.contains("Q") || s.contains("9")) {
            out.println("YES");
        }
        else {
            out.println("NO");
        }
        out.flush();
        out.close();
    }
}


import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long l = sc.nextLong();
		long r = sc.nextLong();
		long gcd = sc.nextLong();
		long lcm = sc.nextLong();
		if(lcm%gcd!=0){
			System.out.println("0");
		}
		else{
			long res = lcm/gcd;
			int p = factors(res,l,r);
			System.out.println(p);
		}
	}
	static int factors(long res,long l,long r){
		int count = 0;
		for(int i=1;i*i<=res;i++){
			if(res%i==0 && i>=l && i<=r){
				if(i!=res/i && res/i>=l && res/i<=r){
					if(gcd(i,res/i)){
						count= count+2;
					}
				}
			}
		}
		return count;
	}
	static boolean gcd(long a,long b){
		if(a==b && a==1){
			return true;
		}
		else if(a>b){
			return gcd(a-b,b);
		}
		else if(b>a){
			return gcd(a,b-a);
		}
		return false;
	}
}


import java.io.FileInputStream;
import java.util.Scanner;

public class Solution {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//      Scanner sc = new Scanner(new FileInputStream("/home/camoroh13/temp/input.txt"));
        String n = sc.nextLine();
        String m = sc.nextLine();
        String ans="OK";
        if (n.length() != m.length() || m.startsWith("0")) {
            ans = "WRONG_ANSWER";
        } else {
            String tm = "";
            int[] c = new int[10];
            c[0] = c[1] = c[2] = c[3] = c[4] = c[5] = c[6] = c[7] = c[8] = c[9] = 0;

            for (int i=0;i < 10; i++) {
                String str = i+"";
                int pos = n.indexOf(str);
                while (pos > -1) {
                    c[i]++;
                    pos = n.indexOf(str, pos+1) ;
                }
            }

            int k = 1;
            while (k <= 9 && c[k] == 0) {
                k++;
            }

            if (k < 10) {
                for (int j=0; j< c[k]; j++) {
                    tm += k+"";
                    break;
                }
            }
                for (int j=1; j<= c[0]; j++) {
                    tm += "0";
                }
            for (int i=1;i < 10; i++) {
                String str = i+"";
                for (int j=1; j<= c[i]; j++) {
                    tm += str;
                }
            }

          if (!tm.equals(m)) {
                ans = "WRONG_ANSWER";
            }
        }

        System.out.println(ans);
        sc.close();
    }

}


import java.util.*;
public class rohmbus{
  public static void main(String[] args) {
    Scanner sc =new Scanner (System.in);
    int n=sc.nextInt();
    System.out.println(solve(n));
  }
  staticint solve(int n){
    if(n==1||n==0)
    return n;
    else
    return (int)(Math.pow(n,2)+Math.pow(n-1,2));
  }
}


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

 public class Main {
	 //****************/////////*
	 public static int TernarySearch(int a,int b){
		 int min = a ; int max= b;
		 for(int i=1;i<=400; i++)
		 {
			 int g= min+(max-min)/3;
			 int h = min + 2*(max-min)/3;
			 if(f(arr[h])>f(arr[g]))
				 max=h;
			 else
				 min=g;

		 }
		 return (min+max)/2 ;

	 }

	public static void main(String args[]){
	Scanner sc= new Scanner(System.in);
	long n =sc.nextLong();
	long k =sc.nextLong();
	if(n==1){System.out.println(0);return ;}
	if(n<=k){System.out.println(1);return ;}
	long max= (k*(k-1)/2)+1 ;
	if(n>max){System.out.println(-1);return;}
	n = n-1 ;
	k=k-1;
	long numb = 0 ;
	long f =1L;long l= (long)k ;

	long mid =(f+l)/2;long ans =-1;
	for(int i=1;i<100;i++)

	{
		mid = (f + l) / 2;
        if ((k*(k + 1)) / 2 - (mid*(mid + 1)) / 2 >= n)
        {
             numb = mid ;
            f = mid+1;
        }
        else l = mid-1;
	}
	System.out.println(k-mid);

	}

	}


import java.io.*;
import java.util.Scanner;
import java.lang.Object;

public class Chess {
    private int[][] board;

    public int chess(String rook, String knight) {

    int N = 8;
    board = new int[N][N];

    int a = Integer.parseInt("" + rook.charAt(1)) - 1;
    int b = Integer.parseInt("" + knight.charAt(1)) - 1;

    int r = (int) (rook.charAt(0) - 'a');
    int k = (int) (knight.charAt(0) - 'a');

    board[b][k] = 1;

    for (int i = -1; i <=1; i+=2) {

        int m = b + i;
        if (m > -1 && m < N) {
           int n = k+2;
           if (n > -1 && n < N) {
               board[m][n] = 1;
           }
           n = k-2;
           if (n > -1 && n < N) {
               board[m][n] = 1;
           }
        }

        m = a + i;
        if (m > -1 && m < N) {
           int n = r+2;
           if (n > -1 && n < N) {
               board[m][n] = 1;
           }
           n = r-2;
           if (n > -1 && n < N) {
               board[m][n] = 1;
           }
        }
    }

    for (int i = -2; i <=2; i+=4) {

        int m = b + i;
        if (m > -1 && m < N) {
           int n = k+1;
           if (n > -1 && n < N) {
               board[m][n] = 1;
           }
           n = k-1;
           if (n > -1 && n < N) {
               board[m][n] = 1;
           }
        }

        m = a + i;
        if (m > -1 && m < N) {
           int n = r+1;
           if (n > -1 && n < N) {
               board[m][n] = 1;
           }
           n = r-1;
           if (n > -1 && n < N) {
               board[m][n] = 1;
           }
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            //rook
            if (i == a || j == r) {
                board[i][j] = 1;
            }
        }
    }

    int sum = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j<N; j++) {
            sum += board[i][j];
        }
    }

    return (64 - sum);

    }

    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String rook = sc.nextLine();
    String knight = sc.nextLine();
    Chess t = new Chess();
    int total = t.chess(rook, knight);
    System.out.println(total);

    }
}


import java.util.Scanner;
public class HelloWorld{

     public static void main(String []args){
        Scanner scan = new Scanner(System.in);
        int number = scan.nextInt();

        while (number > 5){
            number = number - 5;
            number = (number + 1)/2;
            }
        }

        if (number == 5){
            System.out.println("Howard");
        } else {
            if (number == 4){
                System.out.println("Rajesh");
            } else {
                if (number == 3){
                    System.out.println("Penny");
                } else {
                    if (number == 2){
                        System.out.println("Leonard");
                    } else {
                        if (number == 1){
                            System.out.println("Sheldon");
                        }
                    }
                }
            }
        }
     }
}


import java.util.Scanner;
public class CF394A {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        sc.close();
        if (str.length()%2 != 0){
            System.out.println("Impossible");
        } else {
            int len = (str.length() - 2)/2;
            String result = "|+";
            for(int i = 0; i < len - 1; i++){
                result += "|";
            }
            result += "=";
            for(int i = 0; i < len; i++){
                result += "|";
            }
            System.out.println(result);
        }

    }


public class B {

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

    public B()
    {
        Scanner s = new Scanner();
        int n = s.nextInt();
        int m = s.nextInt();
        if(n == m || (m + n) % 2 == 0)
        {
            char[] narray = s.readNextLine().toCharArray();
            char[] marray = s.readNextLine().toCharArray();
            StringBuilder sb1 = new StringBuilder();
            StringBuilder sb2 = new StringBuilder();

            if(m > n)
                m = n;
            else if(n > m)
                n = m;

            for(int i = 0; i < n; i++)
            {
                if(narray[i] == '>')
                    sb1.append("1");
                else
                    sb1.append("0");
            }
            for(int i = 0; i < m; i++)
            {
                if(marray[i] == '^')
                    sb2.append("1");
                else
                    sb2.append("0");
            }
            if(sb1.toString().equals(sb2.toString()))
                System.out.println("YES");
            else
                System.out.println("NO");
        }
        else
        {
            System.out.println("NO");
        }
    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(Reader in) {
            br = new BufferedReader(in);
        }

        public Scanner() {
            this(new InputStreamReader(System.in));
        }

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

        // Slightly different from java.util.Scanner.nextLine(),
        // which returns any remaining characters in current line,
        // if any.
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

public class Mainn {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader scn = new FastReader();

		long end = scn.nextInt(), cap = scn.nextInt(), pump = scn.nextInt(), round = 2 * scn.nextInt(), r = 0, gas = cap, stop = 0;
		long tDist = round * end;

		if(cap >= tDist) {
			System.out.println(0);
			return;
		}

		if((cap < 2 * pump || cap < 2 * (end - pump)) && round > 2) {
			System.out.println(-1);
			return;
		}

		if(round == 1 && (pump > cap || (end - pump) > cap){
			System.out.println(-1);
			return;
		}

		while(r < round) {
			gas -= pump;
			r++;
			if(gas >= 2 * (end - pump) && (round - r) > 1) {
				r += 2;
				gas -= 2 * (end - pump);
			} else if((round - r) > 1){
				stop++;
				r += 2;
				gas = cap - 2 * (end - pump);
			} else if((round - r) == 1 && gas >= (end - pump)){
				r++;
			} else if((round - r) == 1) {
				r++;
				stop++;
			}

			if(r >= round) {
				break;
			}

			if((round - r) == 1) {
				if(gas < pump) {
					stop++;
				}
				r++;
				break;
			} else if(gas >= 2 * pump) {
				r++;
				gas -= pump;
			} else if(gas < 2 * pump){
				gas = cap - pump;
				stop++;
				r++;
			}
		}

		System.out.println(stop);
	}
}


import java.util.Scanner;

public class VK_2016_A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		if(A % 2 == 1){
			int ans = 1;
			while(A != 1){
				ans++;
				A -= 2;
			}
		}else{
			int ans = 1;
			while(A != N){
				ans++;
				A += 2;
			}
		}
		System.out.println(ans);
	}
}


package javaapplication3;

import java.util.Scanner;

public class JavaApplication3 {

    public static void main(String[] args) {
         Scanner in=new Scanner(System.in);
     long n,a,b,c,k,m;
     a=in.nextLong();
     b=in.nextLong();

    if (a*b%2==0) m=a*b/2; else m=(a*b+1)/2;
    if ((a==1)||(b==1)) m=a*b;
    if ((a==2)&(b==2)) m=4;
    if(((a==2)&(b%2==1))||((b==2)&(a%2==1))) m=(a*b+2)/2;
    if(((a==2)&(b%4==2))||((b==2)&(a%4==2))) m=(a*b+4)/2;
     System.out.println(m);
    }
}


import java.io.*;
import java.util.*;
public class A57 {
    static int n;
    public static void main(String[] args) throws IOException   {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        n = Integer.parseInt(st.nextToken());
        int x1 = Integer.parseInt(st.nextToken());
        int y1 = Integer.parseInt(st.nextToken());
        int x2 = Integer.parseInt(st.nextToken());
        int y2 = Integer.parseInt(st.nextToken());
        int[] dx = new int[]{-1,1,0,0};
        int[] dy = new int[]{0,0,-1,1};
        int[][] grid = new int[n+1][n+1];
        for(int i = 0; i <= n; i++)
            Arrays.fill(grid[i], 1 << 20);
        grid[x1][y1] = 0;
        LinkedList<State> q = new LinkedList<State>();
        q.add(new State(x1,y1));
        while(!q.isEmpty())     {
            State curr = q.removeFirst();
            if(curr.x == x2 && curr.y == y2)
                break;
            for(int i = 0; i < 4; i++)      {
                int outX = curr.x + dx[i];
                int outY = curr.y + dy[i];
                if(grid[outX][outY] > 1 + grid[curr.x][curr.y]) {
                    grid[outX][outY] = 1 + grid[curr.x][curr.y];
                    q.addLast(new State(outX, outY));
                }
            }
        }
        System.out.println(grid[x2][y2]);
    }
    public static boolean isValid(int x, int y)     {
        return x>=0 && y>=0 && x<=n && y<=n && ((x==0 || x==n) || (y==0 || y==n));
    }
    static class State {
        public int x,y;
        public State(int a, int b)  {
            x=a;
            y=b;
        }
    }
}


=import java.util.Scanner;

public class Quiz {
	static int x = 1000000009;
	public static int initialScore(int n,int k)
	{
		if (n==0)
			return 0;
		int l = initialScore(n-1, k);
		return (int) (1L*(l+k)*2)%x;
	}
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int rightSeq = k-1;
		int a = Math.min(m/rightSeq, n-m+1);
		int score = Math.min(m,a*(k-1));
		m -= score;
		score += m%k;
		m -= m%k;
		int initialScore = initialScore(m/k,k);

		System.out.println(initialScore+score);
	}
}


public class Main {
    static final int SIZE = 15000;

    public static void main(String[] args) throws Throwable {
        int seed = 1;
        int[][] a = new int[SIZE][SIZE], b = new int[SIZE][SIZE];
        for (int i = 0; i < SIZE; i++) {
            for (int j = 0; j < SIZE; j++) {
                a[i][j] = seed; seed = 217 * seed + 71;
                b[i][j] = seed; seed = 217 * seed + 71;
            }
        }
    }
}


import java.util.Scanner;
public class StraightA{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        float x, avg = 0;
        float currentSum = 0;
        for (int i = 0; i <n; i++){
            x = scan.nextInt();
            currentSum += X;

        }
        avg = Math.round(currenrSum / n);
        int c = 0;
        while (avg < k){
            n++;
            currentSum += k;
            avg = Math.round(currentSum / n);
            c++
        }
        System.out.println(c);
    }
}


import java.util.*;
public class Main
{
	public static void main(String[] args) {
	   Scanner s=new Scanner(System.in);
	   int teama=s.nextInt();
	   int teamb=s.nextInt();
	   int maxa=s.nextInt();
	   int maxb=s.nextInt();
	   int total=s.nextInt();
	   int min=total-(((maxa-1)*teama)+((maxb-1)*teamb));
	   if(min<0){
	       min=0;
	   }
	   int max=0;
	   if(maxa<maxb)
	   {
	      max=teama;
	      total=total-(teama*maxa);
          int nn=total/maxb;
          while(!nn<=teamb)
          nn--;
          max=max+nn;
	   }
	   else
	   {
	      max=teamb;
	      total=total-(teamb*maxb);
	      int nn=total/maxa;
          while(!nn<=teama)
          nn--;

          max=max+nn;
	   }
	   System.out.println(min+" "+max);
	}
}


import java.util.Scanner;
import java.util.HashMap;
public class Pas {

	public static void main(String[] args) {
		Scanner Scan = new Scanner(System.in) ;
		String input = Scan.next() ;
		String Tab[] = new String[8];
		int S=0, E=10 ;

        for (int i = 0; i <80; i++) {
            Tab[i] = input.substring(S, E);
            S= S+10;
            E= E+10;
        }
        HashMap Mapping = new HashMap();

        for (int i = 0; i < 10; i++) {
            Mapping.put(Scan.next(), i );
        }

        for (int i = 0; i < 8; i++) {
            System.out.print(Mapping.get(Tab[i]));
        }


import java.util.Scanner;

public class SpecialOlympics {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] r, x, y;
        r = new int[4]; x = new int[4]; y = new int[4];
        x[0] = x[1] = sc.nextInt();
        y[0] = y[1] = sc.nextInt();
        r[0] = sc.nextInt(); r[1] = sc.nextInt();

        x[2] = x[3] = sc.nextInt();
        y[2] = y[3] = sc.nextInt();
        r[2] = sc.nextInt(); r[3] = sc.nextInt();

        int ans = 0;
        for (int cc = 0; cc < 4; cc++)
        {
            boolean ok = true;
            for (int i = 0; i < 4; i++)
            {
                if(i != cc)
                    if(intersect(r[cc],r[i],x[cc],y[cc],x[i],y[i]))
                        ok = false;
            }
            if(cc/2  == 0)
            {
                if(between(r[2], r[3], x[2], y[3], x[cc], y[cc], r[cc]))
                    ok = false;
            }else if(between(r[0], r[1], x[1], y[1], x[cc], y[cc], r[cc]))
                ok = false;

            if(ok) ans++;
        }
        System.out.println(ans);
    }

    static double eps = 1e-9;

    public static boolean intersect(int r1, int r2, int x1, int y1, int x2, int y2)
    {
        double dist  = Math.sqrt(sq(x1-x2)+ sq(y1-y2));
        if(dist > Math.abs(r1+r2)-eps || dist < Math.abs(r2-r1)+eps)
            return false;
        return true;
    }

    public static boolean between(int r1, int r2, int x1, int y1, int x2, int y2, int r)
    {
        double dist  = Math.sqrt(sq(x1-x2)+ sq(y1-y2));
        return dist < r- Math.min(r1, r2) + eps && dist < Math.max(r1,r2)-r + eps;
    }

    public static int sq(int n)
    {
        return n*n;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Comparator;

public class d1 extends PrintWriter {

    static BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
    // static Scanner s=new Scanner(System.in);
    d1 () { super(System.out); }
    public static void main(String[] args) throws IOException{
        d1 d1=new d1();d1.main();d1.flush();
    }
    void main() throws IOException {
        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        StringBuffer sb = new StringBuffer();
        StringBuffer sb1 = new StringBuffer();
        PrintWriter out = new PrintWriter(System.out);
//       String[] s11 = s();
        int t=1;
        while(t-->0){
            String[] ss=s(); n=i(ss[0]);
            String[] s21=s();
            String[] s3=s();
              int r1=i(s21[0]);int s1=i(s21[1]);int p1=i(s21[2]);int r2=i(s3[0]);int s2=i(s3[1]);int p2=i(s3[2]);
               long max=Math.min(r1,s2)+Math.min(s1,p2)+Math.min(p1,r2);
             long min1=0; min=Long.MAX_VALUE;
             min1=Math.min(r1,r2);
             long min2=Math.min(r2-min1+s2,s1);
              min1+=min2;
              min1+=Math.min(p1,p2+s2-min2);
              min=Math.min(min,n-min1);

            min1=Math.min(s1,s2);
            min2=Math.min(s2-min1+p2,p1);
            min1+=min2;
            min1+=Math.min(r1,r2+p2-min2);
            min=Math.min(min,n-min1);

            min1=Math.min(p1,p2);
            min2=Math.min(p2-min1+r2,r1);
            min1+=min2;
            min1+=Math.min(s1,s2+r2-min2);
            min=Math.min(min,n-min1);

          go(r1,r2,s1,s2,p1,p2,0,1);
            System.out.println((min)+" "+max);
        }
//        System.out.println(sb.toString());
    }long min;int n;
    public void go(int r1,int r2,int s1,int s2,int p1,int p2,int ans,int count){
        if(count==1){
//            count++;
            go(r1-Math.min(r1,r2-Math.min(r2,s1)),r2-Math.min(r2,s1)-Math.min(r1,r2-Math.min(r2,s1)),s1-Math.min(r2,s1),s2,p1,p2,ans+Math.min(r2,s1)+Math.min(r1,r2-Math.min(r2,s1)),count+1);
            go(r1-Math.min(r1,r2),r2-Math.min(r1,r2)-Math.min(s1,r2-Math.min(r1,r2)),s1-Math.min(r2-Math.min(r1,r2),s1),s2,p1,p2,ans+Math.min(r1,r2)+Math.min(s1,r2-Math.min(r1,r2)),count+1);
        }else if(count==2){
//            count++;
            // r2 p2
            // s1 p1
//            System.out.println(ans);
            go(r1-Math.min(r1,p2),r2,s1,s2,p1-Math.min(p2-Math.min(r1,p2),p1),p2-Math.min(r1,p2)-Math.min(p1,p2-Math.min(r1,p2)),ans+Math.min(r1,p2)+Math.min(p1,p2-Math.min(r1,p2)),count+1);
            go(r1-Math.min(r1,p2-Math.min(p2,p1)),r2,s1,s2,p1-Math.min(p2,p1),p2-Math.min(p2,p1)-Math.min(r1,p2-Math.min(p2,p1)),ans+Math.min(p2,p1)+Math.min(r1,p2-Math.min(p2,p1)),count+1);

        }else if(count==3){
//            count++;
            //p2 s2
            //r1 s1
//            System.out.println(ans);
            go(r1,r2,s1-Math.min(s1,s2-Math.min(s2,p1)),s2-Math.min(s2,p1)-Math.min(s1,s2-Math.min(s2,p1)),p1-Math.min(s2,p1),p2,ans+Math.min(s2,p1)+Math.min(s1,s2-Math.min(s2,p1)),count+1);
            go(r1,r2,s1-Math.min(s1,s2),s2-Math.min(s1,s2)-Math.min(p1,s2-Math.min(s1,s2)),p1-Math.min(s2-Math.min(s1,s2),p1),p2,ans+Math.min(s1,s2)+Math.min(s1,s2-Math.min(s1,s2)),count+1);
        }else{
             min=Math.min(min,n-ans);return;
        }
    }
    public void arr(int[] a,int n) throws IOException{
//        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        String[] s2=s();
        for(int i=0;i<n;i++){
            a[i]=i(s2[i]);
        }
    }
    public void sort(int[] a,int l,int h){
        if(l==h) return;
        int mid=(l+h)/2;

        sort(a,l,mid);
        sort(a,mid+1,h);
        merge(a,l,(l+h)/2,h);
    }
    void merge(int arr[], int l, int m, int r)
    {
        int n1 = m - l + 1;
        int n2 = r - m;
        int L[] = new int[n1];
        int R[] = new int[n2];
        for (int i = 0; i < n1; ++i)
            L[i] = arr[l + i];
        for (int j = 0; j < n2; ++j)
            R[j] = arr[m + 1 + j];
        int i = 0, j = 0;
        int k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            }
            else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }
        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    static long gcd(long a, long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
    static String[] s() throws IOException {
        return s.readLine().trim().split("\\s+");
    }

    static int i(String ss) {
        return Integer.parseInt(ss);
    }
    static long l(String ss) {
        return Long.parseLong(ss);
    }
}
class Student {
    long  a;int b;int c;
    public Student(int a,int b,int c) {
        this.a=a;this.c=c;this.b=b;
    }
}
class Pair {
    int  a,b,c;
    public Pair(int  a,int b,int c){
        this.a=a;this.b=b;this.c=c;}
}
class Sortbyroll implements Comparator<Student> {

    public int compare(Student a, Student b){
        return   a.b-b.b;}
}


 import java.util.*;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.Math;

public class Main{
   public static void main(String args[]) throws Exception
   {
      BuffredReader br = new BufferedREader(new InputStreamReader(System.in));
      String str = br.readLine();
      int q = 0;
      int a =0;
      int temp_a = 0;
      int temp_q =0;
      int count=0;
      for(int i=0;i<str.length();i++)
      {
         if(str.charAt(i) == 'Q')
         {
            // if(q>0 && a>0)
            // {
            //    count+= Math.max(q,a);
            // }
            if(temp_q!=0 && temp_a!=0)
            {
               q=temp_q;
               a=temp_a;
               temp_q=1;
            }
            else
            {
               temp_q++;
            }
         }
         else if(str.charAt(i) == 'A')
         {
            if(q!=0)
            {
               temp_a++;
            }
         }
      }
      System.out.println(q*a);
   }
}


import java.math.BigInteger;
import java.util.Scanner;

/**
 * Created by andreilupu on 18/02/2016.
 */
public class J {

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

    public J(){
        solve();
    }

    private void solve() {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        BigInteger v = new BigInteger(s);
        System.out.println(v.divide(new BigInteger("2520")));
    }


/*
 *
 * @author Mukesh Singh
 *
 */

import java.io.*;
import java.util.*;
import java.text.DecimalFormat;
@SuppressWarnings("unchecked")
public class AB {
	//solve test cases
	void solve() throws Exception {
		int sum1 = 0 ; int sum2 = 0 ;
		for(int i = 0 ; i < 8 ; ++i ){
			String st = in.nextToken();
			for(int j= 0 ; j < st.length(); ; ++j ){
				char ch = st.charAt(j);
				if(ch=='Q') sum1+= 9;
				if(ch=='R') sum1+= 5;
				if(ch=='B') sum1+= 3;
				if(ch=='N') sum1+= 3;
				if(ch=='P') sum1+= 1;
				if(ch=='q') sum2+= 9;
				if(ch=='r') sum2+= 5;
				if(ch=='b') sum2+= 3;
				if(ch=='n') sum2+= 3;
				if(ch=='p') sum2+= 1;

			}
		}
		//System.out.println(sum1+" "+sum2);
		if(sum1== sum2) System.out.println("Draw");
		if(sum1> sum2) System.out.println("White");
		if(sum1< sum2) System.out.println("Black");
	}

	//@ main function
	public static void main(String[] args) throws Exception {
		new AB();
	}

	InputReader in;
	PrintStream out ;
	DecimalFormat df ;
	AB() {
		try {
			File defaultInput = new File("file.in");
			if (defaultInput.exists())
				in = new InputReader("file.in");
			else
				in = new InputReader();
			defaultInput = new File("file.out");
			if (defaultInput.exists())
				out = new PrintStream(new FileOutputStream("file.out"));
			else
				out = new PrintStream(System.out);
			df = new DecimalFormat("######0.00");
			solve();
			out.close();
		}
		catch (Exception e) {
			e.printStackTrace();
			System.exit(261);
		}
	}

	class InputReader {
		BufferedReader reader;
		StringTokenizer tokenizer;

		InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		InputReader(String fileName) throws FileNotFoundException {
			reader = new BufferedReader(new FileReader(new File(fileName)));
		}

		String readLine() throws IOException {
			return reader.readLine();
		}

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

		boolean hasMoreTokens() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				String s = readLine();
				if (s == null)
					return false;
				tokenizer = new StringTokenizer(s);
			}
			return true;
		}

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

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

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


import java.util.*;

public class Solution
{
    public static void main(String args[]) throws IOException
    {
        BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
        int  n=Integer.readLine(br.readLine());
        int a=1234567;
        int b=123456;
        int c=1234;
        int total=a+b+c;
        if(n<total)
        {
            System.out.println("NO");
            return;
        }
        if(n%a ==0 || n%b==0 || n%c==0 || n%(a+b)==0 || n%(a+c)==0 || n%(b+c)==0 || n%total==0)
        System.out.println("YES");
        else
        System.out.println("NO");
    }
}


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

public class F1 implements Runnable{
	public static void main (String[] args) {new Thread(null, new F1(), "_cf", 1 << 28).start();}

	public void run() {
		DeoxysS fs = new DeoxysS();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("Go!");

		int n = fs.nextInt();
		int k = fs.nextInt();
		int[] a = fs.nextIntArray(n);
		int[] b = fs.nextIntArray(k);

		boolean good = false;

		for(int i = 0; i < n; i++) {
			for(int j = i; j < n; j++) {
				int[] cnts = new int[k];
				for(int ii = i; ii <= j; ii++) {
					if(a[ii] - 1 < k) cnts[a[ii]-1]++;
				}
				boolean nope = false;
				for(int ii = 0; ii < k; ii++) {
					if(cnts[ii] != b[ii]) nope = true;
				}
				if(!nope) good = true;
			}
		}

		if(good) out.println("YES");
		else out.println("NO");

		out.close();
	}

	void sort (int[] a) {
		int n = a.length;
		for(int i = 0; i < 50; i++) {
			Random r = new Random();
			int x = r.nextInt(n), y = r.nextInt(n);
			int temp = a[x];
			a[x] = a[y];
			a[y] = temp;
		}
		Arrays.sort(a);
	}

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

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

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

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

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

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

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

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

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

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

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

	}

}


// package EducationalRound88;

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

public class ProblemE {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int k=Integer.parseInt(st.nextToken());
        int mod=998244353;
        long fact[]=new long[n+1];
        fact[1]=1;
        fact[0]=1;
        for(int i=2;i<=n;i++){
            fact[i]=(fact[i-1]*i)%mod;
        }
        long ans=0;
        for(int i=1;i<=n;i++){
            int p=(n-i)/i;
            int r=k-1;
            if(p<r){
                continue;
            }
            long num=fact[p];
            long den=modexp(fact[r],mod-2,mod);
            den=(den*modexp(fact[p-r],mod-2,mod))%mod;
            num=(num*den)%mod;
            ans=(ans+num)%mod;
        }
        System.out.println(ans);
    }
    public static long modexp(long a,long power,int mod){
        if(power==0){
            return 1;
        }
        if(power==1){
            return a;
        }
        long small=modexp(a,power/2,mod);
        long ans=(small%mod*small%mod)%mod;
        if(power%2!=0){
            ans=(ans%mod*a%mod)%mod;
        }
        return ans;
    }
}


import javafx.util.Pair;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * Created by Ferrumit on 6/28/2016.
 */
public class _507A {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int a[][] = new int[n][2];
        for(int i=0;i<n;i++){
            a[i][0] = i + 1;
            a[i][1] = in.nextInt();
        }
        Arrays.sort(a, new Comparator<int[]>() {
            @Override
            public int compare(int[] a1, int[] a2) {
                return a1[1] - a2[1];
            }
        });
        String ans = "";
        int count = 0;
        int c = 0;
        for(int i=0;i<n;i++)
            if(a[i][1]+count<=k){
                count+=a[i][1];
                c++;
                ans+=(a[i][0]+" ");
            }
        System.out.print(c + "\n" + ans);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;

public class experiment
{

    static int M = 1_000_000_007;
    static int INF = 1_000_000_000;
    static final FastScanner fs = new FastScanner();

    //variable
    static boolean[] column,diag1,diag2;
    public static void main(String[] args) throws IOException {

        int n = fs.nextInt();
        int[] arr = fs.arrayIn(n);
        while(true) {
            boolean bre = false;
            for(int i=0;i<n;i++){
                if(arr[i]%2 == 1) bre = true;
            }
            if(bre) break;
            for(int i=0;i<n;i++) arr[i] >>= 1;
        }
        int sum = 0;
        for(int i=0;i<n;i++) {
            sum += arr[i];
        }
        if(sum%2==1) {
            System.out.println(0);
            return;
        }
        boolean[][]dp = new boolean[sum/2+1][n+1];
        for(int i=0;i<=n;i++) dp[0][i] = 1;

        for(int i=1;i<=sum/2;i++) {
            for(int j=1;j<=n;j++) {
                if(i>=arr[j-1])
                    dp[i][j] = dp[i-arr[j-1]][j-1]  dp[i][j-1];
                else dp[i][j] = dp[i][j-1];
            }
        }
        if(dp[sum/2][n]) {
            for(int i=0;i<n;i++) {
                if(arr[i]%2 == 1) {
                    System.out.println("1\n"+(i+1));
                    return;
                }
            }
        }
        System.out.println(0);
    }

    //function
    static int gcd(int x, int y) {
        if(x == 0) return y;
        return gcd(y%x,x);
    }
    static void premutation(int n, ArrayList<Integer> arr,boolean[] chosen) {
        if(arr.size() == n) {

        }else {
            for(int i=1; i<=n; i++) {
                if(chosen[i]) continue;
                arr.add(i);
                chosen[i] = true;
                premutation(n,arr,chosen);
                arr.remove(i);
                chosen[i] = false;
            }
        }
    }
    static boolean isPalindrome(char[] c) {
        int n = c.length;
        for(int i=0; i<n/2; i++) {
            if(c[i] != c[n-i-1]) return false;
        }
        return true;
    }
    // Template
    static long nCk(int n, int k) {
        return (modMult(fact(n),fastexp(modMult(fact(n-k),fact(k)),M-2)));
    }

    static long fact (long n) {

        long fact =1;
        for(int i=1; i<=n; i++) {
            fact = modMult(fact,i);
        }
        return fact%M;
    }

    static int modMult(long a,long b) {
        return (int) (a*b%M);
    }

    static long fastexp(long x, int y){
        if(y==1) return x;

        long ans = fastexp(x,y/2);
        if(y%2 == 0) return modMult(ans,ans);

        return modMult(ans,modMult(ans,x));
    }

    static final Random random = new Random();

    static void ruffleSort(int arr[])
    {
        int n = arr.length;
        for(int i=0; i<n; i++)
        {
            int j = random.nextInt(n),temp = arr[j];
            arr[j] = arr[i];
            arr[i] = temp;
        }
        Arrays.sort(arr);
    }

    public static class Pairs implements Comparable<Pairs>
    {
        int value,index;
        Pairs(int value, int index) {
            this.value = value;
            this.index = index;
        }
        public int compareTo(Pairs p) {
            return Integer.compare(this.value,p.value);
        }
    }
}
class FastScanner
{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer str = new StringTokenizer("");

    String next() throws IOException
    {
        while(!str.hasMoreTokens())
            str = new StringTokenizer(br.readLine());

        return str.nextToken();
    }

    char nextChar() throws IOException {
        return next().charAt(0);
    }

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

    float nextfloat() throws IOException
    {
        return Float.parseFloat(next());
    }

    double nextDouble() throws IOException
    {
        return Double.parseDouble(next());
    }
    long nextLong() throws IOException
    {
        return Long.parseLong(next());
    }
    byte nextByte() throws IOException
    {
        return Byte.parseByte(next());
    }
    int [] arrayIn(int n) throws IOException
    {
        int  arr[] = new int[n];
        for(int i=0; i<n; i++)
        {
            arr[i] = nextInt();
        }
        return arr;
    }
}


    import java.io.*;
    import java.text.*;
    import java.util.*;
    import java.util.regex.*;

    public class Main{
        static class Run implements Runnable{
            //TODO parameters
            final boolean consoleIO = true;
            final String inFile = "input.txt";
            final String outFile = "output.txt";

            String s;
            StringBuffer b;
            int len;

            void next() {
                int len = b.length();
                int carry = 1;
                int i = 0;

                while(i < len && carry == 1) {
                    if(b.charAt(i) == '4') {
                        b.setCharAt(i, '7');
                        carry = 0;
                    }
                    else
                        b.setCharAt(i, '4');

                    ++i;
                }

                if(carry == 1)
                    b.append('4');
            }

            String unz(String st) {
                StringBuffer buf = new StringBuffer(st);
                boolean key = false;

                for(int i = 0; i < buf.length(); ++i) {
                    char cur = buf.charAt(i);

                    if(cur == '4' || cur == '7')
                        key = true;
                    else
                        if(key)
                            key = !key;
                        else
                            buf.deleteCharAt(i--);
                }

                return buf.toString();
            }

            int count() {
                int r = 0;
                int i = 0;

                while(true) {
                    int j = s.indexOf(b.toString(), i);
                    if(j == -1)
                        break;

                    ++r;
                    i = j + 1;
                }

                return r;
            }

            @Override
            public void run() {
                s = unz(nextLine());
                len = s.length();

                int max = 0;
                String maxs = null;
                b = new StringBuffer("4");

                do {
                    int cur = count();
                    if(cur > max) {
                        max = cur;
                        maxs = new String(b);
                    }

                    next();
                } while(!(b.charAt(0) == '7' && b.length() == len));

                print(max == 0 ? "-1" : maxs);
                close();
            }
        //=========================================================================================================================
            BufferedReader in;
            PrintWriter out;
            StringTokenizer strTok;

            Run() {
                if (consoleIO) {
                    initConsoleIO();
                }
                else {
                    initFileIO();
                }
            }

            void initConsoleIO() {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            }

            void initFileIO() {
                try {
                    in = new BufferedReader(new FileReader(inFile));
                    out = new PrintWriter(new FileWriter(outFile));
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            void close() {
                try {
                    in.close();
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

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

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

            float nextFloat() {
                return Float.parseFloat(nextToken());
            }

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

            String nextLine() {
                try {
                    return in.readLine();
                } catch (IOException e) {
                    return "__NULL";
                }
            }

            boolean hasMoreTokens() {
                return (strTok == null) || (strTok.hasMoreTokens());
            }

            String nextToken() {
                while (strTok == null || !strTok.hasMoreTokens()) {
                    String line;
                    try {
                        line = in.readLine();
                        strTok = new StringTokenizer(line);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

                return strTok.nextToken();
            }

            void cout(Object o){
                System.out.println(o);
            }

            void print(Object o) {
                out.write(o.toString());
            }

            void println(Object o) {
                out.write(o.toString() + '\n');
            }

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

            String sprintf(String format, Object... args) {
            return MessageFormat.format(format, args);
        }
        }

        static class Pair<A, B> {
            A a;
            B b;

            A f() {
                return a;
            }

            B s() {
                return b;
            }

            Pair(A a, B b) {
                this.a = a;
                this.b = b;
            }

            Pair(Pair<A, B> p) {
                a = p.f();
                b = p.s();
            }
        }

        public static void main(String[] args) throws IOException {
            Run run = new Run();
            Thread thread = new Thread(run);
            thread.run();
        }
    }


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;
import java.lang.Math;

public class Lo {
    public static long gcd(long a, long b){
        if(b==0){
            return a;
        }
        else{
            return gcd(b, a%b);
        }
    }
    public static int coprime(long a, long b){
        if(gcd(a,b)==1){
            return 1;
        }
        else{
            return 0;
        }
    }
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long a = sc.nextLong();
      long b = sc.nextLong();
      ArrayList <Long> A = new ArrayList <Long>();
      ArrayList <Long> B = new ArrayList <Long>();
      for(long i = a; i <= b; i++){
          for(long j = i+1; j <= b; j++){
              if(coprime(i,j)==1){
                  A.add(i);
                  B.add(j);
              }
          }
      }
      int flag = 0;
      for(int i = 0; i < A.size(); i++){
          for(int j = i+1; j < A.size(); j++){
              if(A.get(j)==B.get(i) && coprime(A.get(i),B.get(j))!=1){
                  System.out.print(A.get(i)+" ");
                  System.out.print(B.get(i)+" ");
                  System.out.print(B.get(j));
                  break;
                  flag = 1;
              }
          }
      }
      if(flag==0){
          System.out.print(-1);
      }
    }
}


import java.util.*;
import java.math.*;
public class tester
{
    public static void main(String arg[])
    {
        Scanner s=new Scanner(System.in);
        long a=s.nextLong();
        long b=s.nextLong();
        String s1=Long.toString(a);
        String s2=Long.toString(b);
        if(s1.length()<s2.length())
        {
            char c[]=s1.toCharArray();
            Arrays.sort(c);
            for(int i=c.length-1;i>=0;i--)
                System.out.print(c[i]);
        }
        else
        {
            System.out.println(fun(s1,s2));
        }

    }
    public static int find(String st,char c)
    {
        int max=-1;
        int x=c-48;
        for(int i=0;i<st.length();i++)
        {
            if(st.charAt(i)-48<=x && st.charAt(i)-48>max)
            {
                max=st.charAt(i)-48;
            }
        }
        return max;
    }
    public static String fun(String s1,String s2)
    {
        int x=find(s1,s2.charAt(0));
        String ans="";
        if(x<s2.charAt(0)-48)
        {
            return tmp(s1,x);
        }
        else
        {
            Strint st="";
            boolean f=true;
            for(int i=0;i<s1.length();i++)
            {
                if(s1.charAt(i)-48==x)
                {
                    if(f==false)
                        st+=s1.charAt(i);
                    else
                        f=false;
                }
                else
                    st+=s1.charAt(i);
            }
            char c[]=st.toCharArray();
            Arrays.sort(c);
            String ns1=c.toString();
            String ns2=s2.substring(1,s2.length());
            if(Long.parseLong(ns1)<Long.parseLong(ns2))
            {
                int y=find(s1,s2.charAt(0)-49);
                return tmp(s1,y);
            }
            else
            {
                ans=(char)x+fun(ns1,ns2);
                return ans;
            }
        }

    }
    public static String tmp(String s1,int x)
    {
        String ans="";
        String st="";
            boolean f=true;
            for(int i=0;i<s1.length();i++)
            {
                if(s1.charAt(i)-48==x)
                {
                    if(f==false)
                        st+=s1.charAt(i);
                    else
                        f=false;
                }
                else
                    st+=s1.charAt(i);
            }
            char c[]=st.toCharArray();
            Arrays.sort(c);
            ans+=(char)x;
            for(int i=c.length-1;i>=0;i--)
                ans+=c[i];
        return ans;
    }
}


package Round426;

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

public class Ques2 {

    static class Scan {

        private final InputStream inputStream;
        private final byte[] buffer = new byte[1024];
        private int currentChar;
        private int numChars;
        private SpaceCharFilter filter;

        public Scan() {
            inputStream = System.in;
        }

        public int read() {
            if (numChars==-1)
                throw new InputMismatchException();

            if (currentChar >= numChars) {
                currentChar = 0;
                try {
                    numChars = inputStream.read(buffer);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buffer[currentChar++];
        }

        public String nextLine() {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String str = "";

            try {
                str = br.readLine();
            }
            catch (IOException e) {
            }
            return str;
        }

        public int nextInt() {
            int ch = read();

            while(isSpaceChar(ch))
                ch = read();

            int sgn = 1;

            if (ch == '-') {
                sgn = -1;
                ch = read();
            }

            int res = 0;
            do {
                if(ch < '0' || ch > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += ch - '0';
                ch = read();
            }
            while (!isSpaceChar(ch));

            return res * sgn;
        }

        public long nextLong() {
            int ch = read();

            while (isSpaceChar(ch))
                ch = read();

            int sgn = 1;

            if (ch == '-') {
                sgn = -1;
                ch = read();
            }

            long res = 0;

            do {
                if (ch < '0' || ch > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += ch - '0';
                ch = read();
            }
            while (!isSpaceChar(ch));

            return res * sgn;
        }

        public double nextDouble() {
            int ch = read();

            while (isSpaceChar(ch))
                ch = read();

            int sgn = 1;
            if (ch == '-') {
                sgn = -1;
                ch = read();
            }

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

            return res * sgn;
        }

        public String readString() {
            int ch = read();
            while (isSpaceChar(ch))
                ch = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(ch);
                ch = read();
            }
            while (!isSpaceChar(ch));

            return res.toString();
        }

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

        public String next() {
            return readString();
        }

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

    static class Print {
        private final BufferedWriter bw;

        public Print() {
            this.bw=new BufferedWriter(new OutputStreamWriter(System.out));
        }

        public void print(Object object)throws IOException {
            bw.append(""+object);
        }

        public void println(Object object)throws IOException {
            print(object);
            bw.append("\n");
        }

        public void close()throws IOException {
            bw.close();
        }
    }

    public static void main(String args[]) throws IOException {
        Scan sc = new Scan();
        Print pr = new Print();

        int n, k, c=0;
        n = sc.nextInt();
        k = sc.nextInt();

        String str = sc.next();
        int arr[][] = new int[26][2];

        for(int i=n-1; i>=0; i--) {
            if (arr[str.charAt(i) - 65][0] == 0)
                arr[str.charAt(i) - 65][0] = i;
        }

        for(int i=0; i<n; i++) {
            if (arr[str.charAt(i) - 65][1] == 0) {
                arr[str.charAt(i) - 65][1] = 1;
                c++;
            }
            if(c>k) {
                pr.println("YES");
                pr.close();
                return;
            }
            if (arr[str.charAt(i) - 65][0] == i) {
                c--;
            }
        }

        pr.println("NO");
        pr.close();

    }

}


import java.util.*;
public class Main{
     public static void main(String ... S){
          Scanner sc = new Scanner(System.in);
          int a[] = new a[4];
          a[0] =sc.nextInt();
          a[1]= sc.nextInt();
          a[2] = sc.nextInt();
          a[3] = sc.nextInt();
          Arrays.sort(a);
          if(2*a[2] < a[1] + a[2] + a[0])
            System.out.println("TRIANGLE");
          else if(a[2] >= a[0] + a[1])
            System.out.println("SEGMENT");
          else System.out.println("IMPOSSIBLE");
     }
}


import java.util.*;
public class polycrapAndLetters {
	public static void main(String args[]){
		Scanner kd=new Scanner(System.in);
		int a=kd.nextInt();
		String s=kd.next();
		int answer=0;
		int number[]=new int[27];
		int i=0;
		do{
			if(s.charAt(i)<97){
				number=new int[27];
			}
			else{
				if(number[s.charAt(n)-96]==0){
					number[s.charAt(n)-96]=1;
					number[0]++;
					if(number[0]>answer){
						answer=number[0];
					}
				}
			}
			i++;
		}while(i<a);
		System.out.println(answer);

	}

}


import java.util.*;

public class Digits {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        final int L = scan.nextInt();
        final int R = scan.nextInt();

        int place1T, place2T, place3T, place4T, place5T, place6T;
        int confirm, last, confirm2 = 0;
        for (int test = L; test <= R; test++) {
            confirm = 0;
            last = test;
            place1T = test/100000;
            test %= 100000;
            place2T = test/10000;
            test %= 10000;
            place3T = test/1000;
            test %= 1000;
            place4T = test/100;
            test %= 100;
            place5T = test/10;
            place6T = test%10;
            if (place1T == 0){
                place1T = 11;
                if (place2T == 0){
                    place2T = 12;
                    if (place3T == 0){
                        place3T = 13;
                        if (place4T == 0){
                            place4T = 14;
                            if (place5T = 0){
                                place5T = 15;
                                if (place6T == 0){
                                    place6T = 16;
                                }
                            }
                        }
                    }
                }
            }
            if (place1T == place2T) {
                confirm = 1;
            }
            if (place1T == place3T) {
                confirm = 1;
            }
            if (place1T == place4T) {
                confirm = 1;
            }
            if (place1T == place5T) {
                confirm = 1;
            }
            if (place1T == place6T) {
                confirm = 1;
            }
            if (place2T == place3T) {
                confirm = 1;
            }
            if (place2T == place4T) {
                confirm = 1;
            }
            if (place2T == place5T) {
                confirm = 1;
            }
            if (place2T == place6T) {
                confirm = 1;
            }
            if (place3T == place4T) {
                confirm = 1;
            }
            if (place3T == place5T) {
                confirm = 1;
            }
            if (place3T == place6T) {
                confirm = 1;
            }
            if (place4T == place5T) {
                confirm = 1;
            }
            if (place4T == place6T) {
                confirm = 1;
            }
            if (place5T == place6T) {
                confirm = 1;
            }
            if (confirm == 0){
                System.out.println(last);
                confirm2 = 1;
                break;
            }
        }
        if (confirm2 == 0){
            System.out.println(-1);
        }
    }
}


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

// this is not good for reading double values.
public class third {
	static long m = 100000007;

	public static void main(String[] args) throws IOException {
		Reader r = new Reader();
		PrintWriter o = new PrintWriter(System.out, false);
		//PrintWriter o = new PrintWriter(new FileOutputStream("file" + ".out"));

			int a = r.nextInt();
		int b=r.nextInt();
		if(a/2<b){
			o.println(3);
		}
		else if(a/2==b)
			o.println(4);
		else{

			int b1=b,b2=b,b3=b;
			int count=0;
			while((b1!=a)&&(b2!=a)&&(b3!=a)){
				int b1b2=b1+b2;
				int b2b3=b2+b3;
				int b1b3=b1+b3;
				int min;
				b1b2=Math.abs(a-b1b2);
				b2b3=Math.abs(a-b2b3);
				b1b3=Math.abs(a-b1b3);
				if(b1b2>=b2b3)
				min=b2b3;
				else min=b1b2;
				if(min>=b1b3)
					min=b1b3;
				else min=min;

				if(min==b1b2)
					b3=(b1+b2-1);
				else if(min==b2b3)
					b1=b2+b3-1;
				else if(min==b1b3)
					b2=b1+b3-1;

				count++;

			}
			o.println(count+2);
		}

		o.close();
	}

	public int[] sieve(int n){
		boolean[] isPrime = new boolean[n+1];
        for (int i = 2; i <= n; i++) {
            isPrime[i] = true;
        }

        // mark non-primes <= n using Sieve of Eratosthenes
        for (int factor = 2; factor*factor <= n; factor++) {

        	// if factor is prime, then mark multiples of factor as nonprime

            if (isPrime[factor]) {
                for (int j = factor; factor*j <= n; j++) {
                    isPrime[factor*j] = false;
                }
            }
        }
  // count primes
        int primes = 0;
        for (int i = 2; i <= n; i++) {
            if (isPrime[i]) primes++;
        }
      int a[]=new int[primes];
      int j=0;
      for (int i = 2; i <= n; i++) {
          if (isPrime[i]) {
        	  a[j]=i;
        	  j++;
          }

      }
		return a;
	}
	// pair object x,y
	static class pair {
		@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;
			pair other = (pair) obj;
			if (x != other.x)
				return false;
			if (y != other.y)
				return false;
			return true;
		}

		int x, y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

	public static long gcd(long a, long b) {
		a = Math.abs(a);
		b = Math.abs(b);
		while (b != 0) {
			long temp = a % b;
			a = b;
			b = temp;
		}
		return a;
	}

	public static int gcd(int a, int b) {
		a = Math.abs(a);
		b = Math.abs(b);
		while (b != 0) {
			int temp = a % b;
			a = b;
			b = temp;
		}
		return a;
	}

	static long[][] modPow(long[][] M, long exp) {
		long[][] result = new long[][] { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } };
		long[][] pow = M;
		while (exp != 0) {
			if ((exp & 1) == 1) {
				result = multiply(result, pow);
			}
			exp >>>= 1;
			pow = multiply(pow, pow);
		}
		return result;
	}

	static long[][] multiply(long[][] A, long[][] B) {
		long[][] C = new long[4][4];
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				long value = 0;
				for (int k = 0; k < 4; k++) {
					value += A[i][k] * B[k][j];
				}
				C[i][j] = value % m;
			}
		}
		return C;
	}

	// input/output
	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

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

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (c == '.')
				while ((c = read()) >= '0' && c <= '9')
					ret += (c - '0') / (div *= 10);
			if (neg)
				return -ret;
			return ret;
		}

		public int[] readIntArray(int size) throws IOException {
			int[] arr = new int[size];
			for (int i = 0; i < size; i++)
				arr[i] = nextInt();
			return arr;
		}

		public long[] readLongArray(int size) throws IOException {
			long[] arr = new long[size];
			for (int i = 0; i < size; i++)
				arr[i] = nextLong();
			return arr;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}
}


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

public class position {

    InputStream is;
    PrintWriter out;

    long maxl = (long) 4e18, mod = (long)1e9 + 7L;

    void solve(){
        //Enter code here utkarsh
        BigDecimal a = new BigDecimal(ns());
        BigDecimal b = new BigDecimal(ns());
        int c = ni();
        BigDecimal x = a.divide(b, 1234, RoundingMode.CEILING);
        String s = x.toString();
        int i = s.indexOf('.');
        char j = s.indexOf((char)(c + '0'), i+1);
        if(j == -1 || j > 1000) out.println("-1");
        else        out.println(j - i);
    }

    long modpow(long base, long exp, long modulus) { base %= modulus; long result = 1L; while (exp > 0) { if ((exp & 1)==1) result = (result * base) % modulus; base = (base * base) % modulus; exp >>= 1; } return result;
    }

    public static void main(String[] args) { new utkarsh().run();
    }
    void run(){ is = System.in; out = new PrintWriter(System.out); solve(); out.flush();
    }

    byte input[] = new byte[1024];
    int len = 0, ptr = 0;

    int readByte(){ if(ptr >= len){ ptr = 0; try{ len = is.read(input); }catch(IOException e){ throw new InputMismatchException(); } if(len <= 0){ return -1; } } return input[ptr++];
    }
    char isSpaceChar(int c){ return !( c >= 33 && c <= 126 );
    }
    int skip(){ int b = readByte(); while(b != -1 && isSpaceChar(b)){ b = readByte(); } return b;
    }

    char nc(){ return (char)skip();
    }
    String ns(){ int b = skip(); StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString();
    }
    int ni(){ int n = 0,b = readByte(); boolean minus = false; while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){ b = readByte(); } if(b == '-'){ minus = true; b = readByte(); } if(b == -1){ return -1; } while(b >= '0' && b <= '9'){ n = n * 10 + (b - '0'); b = readByte(); } return minus ? -n : n;
    }
    long nl(){ long n = 0L; int b = readByte(); boolean minus = false; while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){ b = readByte(); } if(b == '-'){ minus = true; b = readByte(); } while(b >= '0' && b <= '9'){ n = n * 10 + (b - '0'); b = readByte(); } return minus ? -n : n;
    }
    double nd(){ return Double.parseDouble(ns());
    }
    float nf(){ return Float.parseFloat(ns());
    }
    int[] na(int n){ int a[] = new int[n]; for(int i = 0; i < n; i++){ a[i] = ni(); } return a;
    }
    char[] ns(int n){ char c[] = new char[n]; int i,b = skip(); for(i = 0; i < n; i++){ if(isSpaceChar(b)){ break; } c[i] = (char)b; b = readByte(); } return i == n ? c : Arrays.copyOf(c,i);
    }
}


import org.apache.commons.lang3.ArrayUtils;

import java.util.*;

/**
 * Created by sourav.p on .
 */

public class SolveA {
    private static int ans = 0;
    private static Queue<String> queue = new LinkedList<>();
    private static Set<String> marked = new HashSet<>();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        String str = in.next();
        queue.add(str);
        marked.add(str);
        while(!queue.isEmpty() && marked.size() < k) {
            String first = queue.poll();
            for(int i=0; i<first.length(); i++) {
                String temp = first;
                char[] tempCh = temp.toCharArray();
                temp = new String(ArrayUtils.remove(tempCh, i));
                if(!marked.contains(temp) && marked.size() + 1 <=k) {
                    queue.add(temp);
                    marked.add(temp);
                    ans += n - temp.length();
                }
            }
        }
        if(marked.size() < k) {
            System.out.println(-1);
        }
        else {
            System.out.println(ans);
        }

    }

}


mport java.util.Scanner;

public class C {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String burger = sc.nextLine();
		long B = 0;
		long S = 0;
		long C = 0;
		long count = 0;
		for(int i = 0; i < burger.length(); i++){
			if(burger.charAt(i) == 'B'){
				B++;
			}
			if(burger.charAt(i) == 'S'){
				S++;
			}
			if(burger.charAt(i) == 'C'){
				C++;
			}
		}
		long nB = sc.nextLong();
		long nS = sc.nextLong();
		long nC = sc.nextLong();

		long pB = sc.nextLong();
		long pS = sc.nextLong();
		long pC = sc.nextLong();

		long r = sc.nextLong();
		while(true){
			long min = Long.MAX_VALUE;
			if(B != 0){
				min = Math.min(nB/B, min);
			}
			else{
				nB = 0;
			}
			if(S != 0){
				min = Math.min(nS/S, min);
			}
			else{
				nS = 0;
			}
			if(C != 0){
				min = Math.min(nC/C, min);
			}
			else{
				nC = 0;
			}
			count+=min;
			nC -= C*min;
			nS -= S*min;
			nB -= B*min;
			if(nC == nS && nS == nB && nB == 0){
				break;
			}
			if(B!= 0 && nB < B){
				r -= (B-nB)*pB;
				nB = B;
			}
			if(S!= 0 && nS < S){
				r-= (S-nS)*pS;
				nS = S;
			}
			if(C!= 0 && nC < C){
				r-= (C-nC)*pC;
				nC = C;
			}
			if(r < 0){
				break;
			}
		}
		long costOfBurger = B*pB + S*pS + C*pC;
		if(r > 0){
			count += r/costOfBurger;
		}
		System.out.println(count);

	}
}


package shower;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Shower {
    public static void main(String[] args) {
        int g[][] = new int[6][6];
        Scanner sc = new Scanner(System.in);
        for (int i = 1; i <=5; i++) {
            for (int j = 1; j <= 5; j++) {
                g[i][j] = sc.nextInt();
            }
        }
        System.out.println(maxHappiness(g));
    }

    public static int maxHappiness(int[][] g) {
        int max = -1;
        List<Integer> values = new ArrayList<Integer>(Arrays.asList(0,1,2,3,4,5));
        do {
            if (getHappiness(g, values) > max) {
                max = getHappiness(g, values);
            }
        }while(next_permutation(values, 5));
        return max;
    }

    public static int getHappiness(int[][] g, List<Integer> values) {
//        int[] newValues = values.stream().mapToInt(Integer::intValue).toArray();
//        int[] newValues
//        int happiness = g[newValues[1]][newValues[2]] + g[newValues[2]][newValues[1]] +
//                g[newValues[2]][newValues[3]] + g[newValues[3]][newValues[2]] +
//                2*(g[newValues[3]][newValues[4]] + g[newValues[4]][newValues[3]] +
//                        g[newValues[4]][newValues[5]] + g[newValues[5]][newValues[4]]);
        int happiness = g[values.get(1)][values.get(2)] + g[values.get(2)][values.get(1)] +
                g[values.get(2)][values.get(3)] + g[values.get(3)][values.get(2)] +
                2*(g[values.get(3)][values.get(4)] + g[values.get(4)][values.get(3)] +
                        g[values.get(4)][values.get(5)] + g[values.get(5)][values.get(4)]);
        return happiness;
    }

    public static boolean next_permutation(List<Integer> values, int n) {
        for (int i = n; i >= 2; i--) {
            if (values.get(i) > values.get(i-1)){
                checkAndSwap(values, i-1, n);
                reverse(values, i, n);
                return true;
            }
        }
        return false;
    }

    public static void checkAndSwap(List<Integer> values, int i, int n) {
        int pos = -1;
        for (int j = i+1; j <= n; j++) {
            if (values.get(j) > values.get(i)){
                pos = j;
            }
        }
        swap(values, i, pos);
    }

    public static void reverse(List<Integer> values, int front, int end) {
        while(end > front) {
            swap(values, front, end);
            front++;
            end--;
        }
    }

    public static void swap(List<Integer> values, int i, int j) {
        int temp = values.get(i);
        values.set(i, values.get(j));
        values.set(j, temp);
    }

}


import java.util.*;

public class Main {
    public static void main (String args[]) {
        Scanner sc = new Scanner(System.in);
        System.out.println(ispalindrome(sc.nextLine());
    }

    public static boolean ispalindrome(String s) {
        for (int i = 0; i < s.length()/2; i++) {
            if (s.charAt(i) != s.charAt(s.length()-1-i))
                return false;
        }
        return true;
    }
}


public class main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

        Scanner entrada= new Scanner(System.in);

        int moneda = entrada.nextInt();

        StringBuilder builder = new StringBuilder();

        for (int i = moneda; i>=1; i--) {
            if (moneda % i == 0) {
                builder.append(i).append(" ");
                moneda = i;
            }
        }


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

public class a {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        String s = scan.nextLine();
        ArrayList<Integer> list = new ArrayList<Integer>();
        for(int i=0; i<num; i++) {
            list = addDigits(list, Integer.parseInt(s.charAt(i)));
        }
        Collections.sort(list);
        for(int i=0; i<list.size(); i++) {
            System.out.print(list.get(i));
        }
    }

    public static ArrayList<Integer> addDigits(ArrayList<Integer> list, int input){

        ArrayList<Integer> output = new ArrayList<Integer>(list);
        if(input == 2){output.add(2);}
        else if(input == 3){output.add(3);}
        else if(input == 4){output.add(2); output.add(2); output.add(3);}
        else if(input == 5){output.add(5);}
        else if(input == 6){output.add(3); output.add(5);}
        else if(input == 7){output.add(7);}
        else if(input == 8){output.add(2); output.add(2); output.add(2); output.add(7);}
        else if(input == 9){output.add(2); output.add(3); output.add(3); output.add(7);}

        return output;
    }
}


import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class A implements Runnable {

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

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer tok = new StringTokenizer("");

    private void init() throws FileNotFoundException {
        Locale.setDefault(Locale.US);
        String fileName = "";
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

    String readString() {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

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

    long readLong() {
        return Long.parseLong(readString());
    }

    double readDouble() {
        return Double.parseDouble(readString());
    }

    int[] readIntArray(int size) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = readInt();
        }
        return a;
    }

    public static void main(String[] args) {
        //new Thread(null, new _Solution(), "", 128 * (1L << 20)).start();
        new A().run();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    @Override
    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    boolean[][] a;
    int[] color;
    int n;

    boolean foundError = false;

    void dfs(int v, int c) {
        color[v] = c;
        for (int to = 0; to < n; to++) {
            if (a[v][to]) {
                if (color[to] == -1) {
                    dfs(to, 1 - c);
                } else {
                    if (color[to] != 1 - c) {
                        foundError = true;
                        return;
                    }
                }
            }
        }
    }

    private void solve() {
        n = readInt();
        int m = readInt();
        a = new boolean[n][n];
        for (int i = 0; i < n; i++) {
            Arrays.fill(a[i], true);
            a[i][i] = false;
        }
        while (m-->0) {
            int x = readInt() - 1;
            int y = readInt() - 1;
            a[x][y] = false;
            a[y][x] = false;
        }

        boolean[] used = new boolean[n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                used[i] |= a[i][j];
            }
        }

        color = new int[n];
        Arrays.fill(color, -1);

        for (int i = 0; i < n; i++) {
            if (color[i] == -1) {
                if (!used[i]) {
                    color[i] = 2;
                    continue;
                }
                dfs(i, 0);
                if (foundError) {
                    out.println("No");
                    return;
                }
            }
        }
        if (foundError) {
            out.println("No");
            return;
        }

        out.println("Yes");
        for (int i = 0; i < n; i++) {
            out.print(color[i] == 0 ? 'a' : (color[i] == 1 ? 'c' : 'b'));
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Random;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

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

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

    static class BGluttony {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            int[] a = new int[n];
            int[] indices = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.readInt();
                indices[i] = i;
            }
            CompareUtils.quickSort(indices, (i, j) -> Integer.compare(a[i], a[j]), 0, n);
            int[] b = new int[n];
            for (int i = 0; i < n; i++) {
                b[indices[DigitUtils.mod(i - 1, n)]] = a[indices[i]];
            }

            for (int x : b) {
                out.append(x).append(' ');
            }
        }

    }

    static class CompareUtils {
        private static final int THRESHOLD = 4;

        private CompareUtils() {
        }

        public static void insertSort(int[] data, IntegerComparator cmp, int l, int r) {
            for (int i = l + 1; i <= r; i++) {
                int j = i;
                int val = data[i];
                while (j > l && cmp.compare(data[j - 1], val) > 0) {
                    data[j] = data[j - 1];
                    j--;
                }
                data[j] = val;
            }
        }

        public static void quickSort(int[] data, IntegerComparator cmp, int f, int t) {
            if (t - f <= THRESHOLD) {
                insertSort(data, cmp, f, t - 1);
                return;
            }
            SequenceUtils.swap(data, f, Randomized.nextInt(f, t - 1));
            int l = f;
            int r = t;
            int m = l + 1;
            while (m < r) {
                int c = cmp.compare(data[m], data[l]);
                if (c == 0) {
                    m++;
                } else if (c < 0) {
                    SequenceUtils.swap(data, l, m);
                    l++;
                    m++;
                } else {
                    SequenceUtils.swap(data, m, --r);
                }
            }
            quickSort(data, cmp, f, l);
            quickSort(data, cmp, m, t);
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }

    static class SequenceUtils {
        public static void swap(int[] data, int i, int j) {
            int tmp = data[i];
            data[i] = data[j];
            data[j] = tmp;
        }

    }

    static class RandomWrapper {
        private Random random;
        public static final RandomWrapper INSTANCE = new RandomWrapper(new Random());

        public RandomWrapper() {
            this(new Random());
        }

        public RandomWrapper(Random random) {
            this.random = random;
        }

        public int nextInt(int l, int r) {
            return random.nextInt(r - l + 1) + l;
        }

    }

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

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

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

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

        public int readInt() {
            int sign = 1;

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

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

            return val;
        }

    }

    static class Randomized {
        public static int nextInt(int l, int r) {
            return RandomWrapper.INSTANCE.nextInt(l, r);
        }

    }

    static class DigitUtils {
        private DigitUtils() {
        }

        public static int mod(int x, int mod) {
            x %= mod;
            if (x < 0) {
                x += mod;
            }
            return x;
        }

    }

    static interface IntegerComparator {
        public int compare(int a, int b);

    }
}


import java.util.*;
public class abc12
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        long a=sc.nextLong();
        long b=sc.nextLong();
        if(a==0 && b==0)
        {
            System.out.print("YES");
            return;
        }
        sc.nextLine();
        String s=sc.nextLine();
        long x[][]=new long[s.length()][2];
        int m=0;
        int n=0;
        for(int i=0;i<s.length();i++)
        {
            char ch=s.charAt(i);
            switch(ch)
            {
                case 'U':n++;break;
                case 'D':n--;break;
                case 'L':m--;break;
                case 'R':m++;break;
                x[i][0]=m;
                x[i][1]=n;
            }
        }
        if(m!=0)
            a%=m;
        if(n!=0)
            b%=n;
        for(int i=0;i<s.length();i++)
        {
            if(a==x[i][0] && b==x[i][1])
            {
                System.out.print("YES");
                return;
            }
        }
        System.out.print("NO");
    }
}


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

public class Mashmokh and Lights {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner lector=new Scanner(System.in);
        int l=lector.nextInt();
        int b=lector.nextInt();
        int luces[]=new int[l];
        int botones[]=new int[b];
        int estados[]=new int[l+1];
        Arrays.fill(estados,0);
        for(int i=0;i<l;i++)
        {
            luces[i]=i;
        }
        for(int p=0;p<b;p++)
        {
            botones[p]=lector.nextInt();
        }
        for(int j=0;j<b;j++)
        {
            if(estados[botones[j]]==0)
            {
                estados[botones[j]]=botones[j];

                if(botones[j]+1<l+1)
                {
                 if(estados[botones[j]+1]==0)
                 {
                    estados[botones[j]+1]=botones[j];
                 }
                }
            }
        }
        for(int k=1;k<l+1;k++)
        {
            System.out.println(estados[k]);
        }
    }
}


import java.util.*;

public class Main {
	public static int[][] array = new int[4][4];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 4; i++) {
			String s = sc.next();
			for (int j = 0; j < 4; j++) {
				char c = s.toCharArray()[j];
				switch (c) {
					case '.':array[i][j] = 0;break;
					case 'x':array[i][j] = 1;break;
					default:array[i][j] = -1;
				}
			}
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (array[i][j] != 0) continue;
				int loc = i*4+j+1;
				switch (loc) {
					case 1:
					case 2:
					case 5:
					case 6:
						if (checkRight(i, j)) {System.out.print("YES");return;}
						if (checkDown(i, j)) {System.out.print("YES");return;}
						if (checkRightDown(i, j)) {System.out.print("YES");return;}
						break;
					case 3:
					case 4:
					case 7:
					case 8:
						if (checkLeft(i, j)) {System.out.print("YES");return;}
						if (checkDown(i, j)) {System.out.print("YES");return;}
						if (checkLeftDown(i, j)) {System.out.print("YES");return;}
						break;
					case 9:
					case 10:
					case 13:
					case 14:
						if (checkRight(i, j)) {System.out.print("YES");return;}
						if (checkUp(i, j)) {System.out.print("YES");return;}
						if (checkRightUp(i, j)) {System.out.print("YES");return;}
						break;
					case 11:
					case 12:
					case 15:
					case 16:
						if (checkLeft(i, j)) {System.out.print("YES");return;}
						if (checkUp(i, j)) {System.out.print("YES");return;}
						if (checkLeftUp(i, j)) {System.out.print("YES");return;}
						break;
				}
				if (loc == 6 || loc == 7 || loc == 10 || loc == 11) {
					if (checkCenterLeft(i, j)) {System.out.print("YES");return;}
					if (checkCenterRight(i, j)) {System.out.print("YES");return;}
				}
				if (loc == 2 || loc == 3 || loc == 6 || loc == 10 || loc == 11 || loc == 14 || loc == 15) {
					if (checkCenterLeftRight(i, j)) {System.out.print("YES");return;}
				}
				if ((loc>4 && loc <13) {
					if (checkCenterUpDown(i, j)) {System.out.print("YES");return;}
				}
			}
		}
		System.out.print("NO");
	}
	public static boolean checkLeft(int x,int y){
		if (array[x][y-1] == 1 && array[x][y-2] == 1) {
			return true;
		}
		return false;
	}
	public static boolean checkRight(int x,int y){
		if (array[x][y+1] == 1 && array[x][y+2] == 1) {
			return true;
		}
		return false;
	}
	public static boolean checkUp(int x,int y){
		if (array[x-1][y] == 1 && array[x-2][y] == 1) {
			return true;
		}
		return false;
	}
	public static boolean checkDown(int x,int y){
		if (array[x+1][y] == 1 && array[x+2][y] == 1) {
			return true;
		}
		return false;
	}
	public static boolean checkLeftUp(int x, int y){
		if (array[x-1][y-1] == 1 && array[x-2][y-2] == 1) {
			return true;
		}
		return false;
	}
	public static boolean checkLeftDown(int x, int y){
		if (array[x+1][y-1] == 1 && array[x+2][y-2] == 1) {
			return true;
		}
		return false;
	}
	public static boolean checkRightDown(int x, int y){
		if (array[x+1][y+1] == 1 && array[x+2][y+2] == 1) {
			return true;
		}
		return false;
	}
	public static boolean checkRightUp(int x, int y){
		if (array[x-1][y+1] == 1 && array[x-2][y+2] == 1) {
			return true;
		}
		return false;
	}
	public static boolean checkCenterRight(int x, int y){
		if (array[x+1][y+1] == 1 && array[x-1][y-1] == 1) {
			return true;
		}
		return false;
	}
	public static boolean checkCenterLeft(int x, int y){
		if (array[x-1][y+1] == 1 && array[x+1][y-1] == 1) {
			return true;
		}
		return false;
	}
	public static boolean checkCenterLeftRight(int x, int y){
		if (array[x][y-1] == 1 && array[x][y+1] == 1) {
			return true;
		}
		return false;
	}
	public static boolean checkCenterUpDown(int x, int y){
		if (array[x-1][y] == 1 && array[x+1][y] == 1) {
			return true;
		}
		return false;
	}
}