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

import static java.lang.Math.*;

public class Main implements Runnable
{
	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;
		private BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

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

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

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

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

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

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

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

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

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

			return res.toString();
		}

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

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

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

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

	int findAngle(Point p1, Point p2)
    {
            return p1.a * p2.a + p1.b * p2.b + p1.c * p2.c + p1.d * p2.d + p1.e * p2.e;
    }

	Point makeVector(Point p1, Point p2)
    {
        return  new Point(p1.a - p2.a, p1.b - p2.b, p1.c - p2.c, p1.d - p2.d, p1.e - p2.e);
    }

    public void run()
	{
		InputReader sc = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		int n = sc.nextInt();

                if(n > 32)
                {
                    w.print("0");
                    w.close();
                    return;
                }

                Point point[] = new Point[n];
                for(int i = 0; i < n; ++i)
                {
                    point[i] = new Point(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
                }

                ArrayList<Integer> ans = new ArrayList<>();
                for(int i = 0; i < n; ++i)
                {
                    int flag = 0;
                    midloop:for(int j = 0; j < n; ++j)
                    {
                        for(int k= 0; k< n && j != i; ++k)
                        {
                            if(k != j && k != i)
                            {
                                Point p1 = makeVector(point[i], point[j]);
                                Point p2 = makeVector(point[i], point[k]);
                                int value = findAngle(p1, p2);
                                if(value > 0)
                                {
                                    flag = 1;
                                    break midloop;
                                }
                            }
                        }
                    }
                    if(flag == 0)
                        ans.add(i);
                }

                w.println(ans.size());
                for(int i = 0; i < ans.size(); ++i)
                {
                    w.println((ans.get(i) + 1));
                }
		w.close();
	}
}
class Point
{
    int a,b,c,d,e;
    Point(int a, int b, int c, int d, int e)
    {
        this.a = a;
        this.b = b;
        this.c = c;
        this.d = d;
        this.e = e;
    }
}


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

public class Main {

    static Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    static Reader fastInput = new Reader();

    public static void main(String[] args) throws IOException {
        int n = fastInput.nextInt();
        if (n > 20) {
            System.out.println(0);
        } else {
            int[][] p = new int[n][5];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 5; j++) {
                    p[i][j] = fastInput.nextInt();
                }
            }
            ArrayList<Integer> good = new ArrayList<>();
            loop:
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (i != j) {
                        for (int k = j + 1; k < n; k++) {
                            if (i != k) {
                                if (getAn(p[i], p[j], p[k]) < 90) {
                                    continue loop;
                                }
                            }
                        }
                    }
                }
                good.add(i + 1);
            }
            System.out.println(good.size());
            for (int i = 0; i < good.size(); i++) {
                System.out.println(good.get(i));
            }
        }
    }

    static double getAn(int[] p1, int[] p2, int[] p3) {
        double dot = 0, aLen = 0, bLen = 0;
        for (int i = 0; i < p1.length; i++) {
            dot += (p2[i] - p1[i]) * (p3[i] - p1[i]);
            aLen += (p2[i] - p1[i]) * (p2[i] - p1[i]);
            bLen += (p3[i] - p1[i]) * (p3[i] - p1[i]);
        }
        return 180 * Math.acos(dot / Math.sqrt(aLen * bLen)) / Math.PI;
    }

    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 String readLine() throws IOException {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') {
                    break;
                }
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

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

        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.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int n = sc.nextInt();
		if(n >= 12) {
			System.out.println("0");
			return;
		}

		int[][] a = new int[n][5];
		for(int i=0; i<n; i++) {
			for(int j=0; j<5; j++) {
				a[i][j] = sc.nextInt();
			}
		}

		ArrayList<Integer> ans = new ArrayList<>();
		for(int i=0; i<n; i++) {
			boolean flag = true;
			loop:
			for(int j=0; j<n; j++) {
				for(int k=0; k<n; k++) {
					if(i == j || j == k || k == i) continue;
					int sum = 0;
					for(int l=0; l<5; l++) {
						sum += (a[j][l] - a[i][l]) * (a[k][l] - a[i][l]);
					}
					if(sum > 0) {
						flag = false;
						break loop;
					}
				}
			}

			if(flag) {
				ans.add(i + 1);
			}
		}

		System.out.println(ans.size());
		for(int i=0; i<ans.size(); i++) {
			System.out.println(ans.get(i));
		}
	}

	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


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

/**
 * Created by Pranav ps on 04-09-2017.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n <= 11){
            long[][] points = new long[n][5];

            for(int i = 0 ; i < n; i++){
                for (int j = 0; j < 5; j++) {
                    points[i][j] = sc.nextLong();
                }
            }

            long[][][] vectors = new long[n][n][5];
            for(int i = 0; i < n; i++){
                for(int j = 0; j < n; j++){
                    for (int k = 0; k < 5; k++) {
                        vectors[i][j][k] = points[j][k] - points[i][k];
                    }
                }
            }

            HashSet<Integer> list = new HashSet<>();

            for(int i = 0; i < n; i++){
                boolean flag = false;
                for (int j = 0; j < n; j++) {
                    for (int k = 0; k < n; k++) {
                        if(!equal(vectors[i][j],vectors[i][k]) && dot(vectors[i][j],vectors[i][k])){
                            list.add(i+1);
                            flag = true;
                            break;
                        }
                    }
                    if(flag)
                        break;
                }
            }

            System.out.println(n - list.size());
            for(int i = 0; i < n; i++){
                if(!list.contains(i+1))
                    System.out.println(i+1);
            }
        }
        else{
            System.out.println(0);
        }
    }
    private static boolean equal(long[] a, long[] b){
        boolean res = true;
        for(int i = 0 ; i < 5; i++){
            res &= a[i]==b[i];
        }
        return res;
    }
    private static boolean dot(long[] a, long[] b){
        long res = 0;
        for(int i = 0 ; i < 5; i++){
            res += a[i]*b[i];
        }

        return res>0;
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int mod=1000000007;
        int[][] bell = new int[4010][4010];
        bell[0][0]=1;
        Scanner scan=new Scanner(System.in);
        int n = scan.nextInt();
        for(int i=1;i<=n;i++){
            bell[i][0]=bell[i-1][i-1];
            for(int j=1;j<=i;j++){
                bell[i][j]=bell[i-1][j-1]+bell[i][j-1];
                bell[i][j]%=mod;
            }
        }
        System.out.println(bell[n][n-1]);
    }
}


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

public class Main {
    private static class Solver {
        private void Solve() {
            final int MOD = (int) 1e9 + 7;

            int n = inp.nextInt();
            String S = " " + inp.next();
            int m = S.length() - 1;

            int[] kmp = new int[m + 1];
            kmp[0] = -1;
            for (int i = 1; i <= m; ++i) {
                kmp[i] = 0;
                for (int j = kmp[i - 1]; j != -1; j = kmp[j]) {
                    if (S.charAt(j + 1) == S.charAt(i)) {
                        kmp[i] = j + 1;
                        break;
                    }
                }
            }

            int[][] nxt = new int[m + 1][2];
            for (int i = 0; i < m; ++i) {
                for (int k = 0; k < 2; ++k) {
                    nxt[i][k] = 0;
                    for (int j = i; j != -1; j = kmp[j]) {
                        if (S.charAt(j + 1) == '(' + k) {
                            nxt[i][k] = j + 1;
                            break;
                        }
                    }
                }
            }

            int[][][] dp = new int[n * 2 + 1][n + 1][m + 1];
            for (int i = 0; i <= n * 2; ++i) {
                for (int j = 0; j <= n; ++j) {
                    for (int k = 0; k <= m; ++k) {
                        dp[i][j][k] = 0;
                    }
                }
            }

            dp[0][0][0] = 1;
            for (int i = 0; i < n * 2; ++i) {
                for (int depth = 0; depth <= n; ++depth) {
                    for (int pref = 0; pref < m; ++pref) {
                        if (dp[i][depth][pref] == 0) {
                            continue;
                        }

                        for (int k = 0; k < 2; ++k) {
                            int newDepth = depth + (k == 0 ? 1 : -1);
                            if (newDepth < 0 || newDepth > n) {
                                continue;
                            }
                            dp[i + 1][newDepth][nxt[pref][k]] += dp[i][depth][pref];
                            if (dp[i + 1][newDepth][nxt[pref][k]] >= MOD) {
                                dp[i + 1][newDepth][nxt[pref][k]] -= MOD;
                            }
                        }
                    }
                }
            }

            int[][] f = new int[n * 2 + 1][n * 2 + 1];
            for (int i = 0; i <= n * 2; ++i) {
                for (int j = 0; j <= n * 2; ++j) {
                    f[i][j] = 0;
                }
            }

            f[0][0] = 1;
            for (int i = 0; i < n * 2; ++i) {
                for (int depth = 0; depth <= n; ++depth) {
                    for (int k = 0; k < 2; ++k) {
                        int newDepth = depth + (k == 0 ? -1 : 1);
                        if (newDepth < 0 || newDepth > n) {
                            continue;
                        }
                        f[i + 1][newDepth] += f[i][depth];
                        if (f[i + 1][newDepth] >= MOD) {
                            f[i + 1][newDepth] -= MOD;
                        }
                    }
                }
            }

            int ans = f[n * 2][0];
            for (int i = 0; i < m; ++i) {
                ans -= dp[n * 2][0][i];
                if (ans < 0) {
                    ans += MOD;
                }
            }
            out.println(ans);
        }
        static InputReader inp;
        static PrintWriter out;
    }

    private static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

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

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

        private int nextInt() {
            return Integer.parseInt(next());
        }
        private long nextLong() {
            return Long.parseLong(next());
        }
        private int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = nextInt();
            }
            return a;
        }
    }
    public static void main(String[] args) throws IOException {
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.setIn(new FileInputStream(new File("input.txt")));
        }
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Solver.inp = new InputReader(inputStream);
        Solver.out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.Solve();
        Solver.out.close();
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class DimaAndHorses {
	static int[] locHorse;
	static List<List<Integer>> enemies;
	public static void main(String[] args){
		FastScanner sc= new FastScanner();

		int n = sc.nextInt();
		int m = sc.nextInt();

		//enemies[i] = list of enemies of horse i
		enemies = new ArrayList<List<Integer>>();
		for(int horse=0;horse<=n;horse++){
			enemies.add(new ArrayList<Integer>());
		}

		for(int i=1;i<=m;i++){
			int h1 = sc.nextInt();
			int h2 = sc.nextInt();
			enemies.get(h1).add(h2);
			enemies.get(h2).add(h1);
		}

		//all horse in group 0 initially
		locHorse = new int[n+1];
		for(int horse=1;horse<=n;horse++){
			jump(horse);
		}
		for(int horse=1;horse<=n;horse++){
			System.out.print(locHorse[horse]);
		}
	}

	public static void jump(int horse){
		int countEnemy = 0;
		for(Integer enemy : enemies.get(horse)){
			if(locHorse[enemy] == locHorse[horse]){
				countEnemy++;
			}
		}
		if(countEnemy >= 2){
			locHorse[horse] = locHorse[horse] == 0 ? 1 : 0;
			for(Integer enemy : enemies.get(horse)){
				if(locHorse[enemy] == locHorse[horse]){
					jump(enemy);
				}
			}
		}
	}

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

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

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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


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

/**
 * @author Egor Kulikov (egor@egork.net)
 */
public class TaskE {
	@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
	private InputReader in;
	private PrintWriter out;
	private int[] dRow = {0, 1, 1};
	private int[] dColumn = {2, 1, -1};

	private void solve() {
		int[][] field = new int[5][9];
		for (int[] row : field)
			Arrays.fill(row, -1);
		int index = 0;
		for (int i = 0; i < 3; i++) {
			for (int j = 2 - i; j < 7 + i; j += 2)
				field[i][j] = index++;
		}
		for (int i = 3; i < 5; i++) {
			for (int j = i - 2; j < 8; j += 2)
				field[i][j] = index++;
		}
		Set<Integer> moves = new HashSet<Integer>();
		for (int i = 0; i < 5; i++) {
			for (int j = 0; j < 9; j++) {
				if (field[i][j] == -1)
					continue;
				for (int k = 0; k < 3; k++) {
					int currentMove = 0;
					int row = i;
					int column = j;
					while (row < 5 && column < 9 && column >= 0 && field[row][column] != -1) {
						currentMove += 1 << field[row][column];
						moves.add(currentMove);
						row += dRow[k];
						column += dColumn[k];
					}
				}
			}
		}
		Integer[] allMoves = moves.toArray(new Integer[moves.size()]);
		int startPosition = 0;
		for (int i = 0; i < 19; i++) {
			if (in.readCharacter() == 'O')
				startPosition += 1 << i;
		}
		boolean[] winner = new boolean[1 << 19];
		for (int i = 1; i <= startPosition; i++) {
			if ((startPosition & i) != i)
				continue;
			for (int move : allMoves) {
				if ((i & move) == move && !winner[i - move]) {
					winner[i] = true;
					break;
				}
			}
		}
		out.println(winner[startPosition] ? "Karlsson" : "Lillebror");
	}

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

	private TaskE() {
		@SuppressWarnings({"UnusedDeclaration"})
		String id = getClass().getName().toLowerCase();
		//noinspection EmptyTryBlock
		try {
//			System.setIn(new FileInputStream(id + ".in"));
//			System.setOut(new PrintStream(new FileOutputStream(id + ".out")));
//			System.setIn(new FileInputStream("input.txt"));
//			System.setOut(new PrintStream(new FileOutputStream("output.txt")));
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
	}

	private void run() {
		//noinspection InfiniteLoopStatement
//		while (true)
//		int testCount = in.readInt();
//		for (int i = 0; i < testCount; i++)
		solve();
		exit();
	}

	@SuppressWarnings({"UnusedDeclaration"})
	private void exit() {
		out.close();
		System.exit(0);
	}

	@SuppressWarnings({"UnusedDeclaration"})
	private static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar, numChars;

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

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

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

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

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

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

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

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

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

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

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

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

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

		public long[] readLongArray(int size) {
			long[] array = new long[size];
			for (int i = 0; i < size; i++)
				array[i] = readLong();
			return array;
		}

		public double[] readDoubleArray(int size) {
			double[] array = new double[size];
			for (int i = 0; i < size; i++)
				array[i] = readDouble();
			return array;
		}

		public String[] readStringArray(int size) {
			String[] array = new String[size];
			for (int i = 0; i < size; i++)
				array[i] = readString();
			return array;
		}

		public char[][] readTable(int rowCount, int columnCount) {
			char[][] table = new char[rowCount][columnCount];
			for (int i = 0; i < rowCount; i++) {
				for (int j = 0; j < columnCount; j++)
					table[i][j] = readCharacter();
			}
			return table;
		}

		public void readIntArrays(int[]... arrays) {
			for (int i = 0; i < arrays[0].length; i++) {
				for (int j = 0; j < arrays.length; j++)
					arrays[j][i] = readInt();
			}
		}
	}
}


import java.util.*;
public class SweetsGame {
	//    0	1	2
	//    3	4	5	6
	//    7	8	9	10	11
	//    12	13	14	15
	//    16	17 	18
	static int [] dp = new int [1<<20];
	static int [] dx = {-2, -1, 1, 2, 1, -1};
	static int [] dy = {0, 1,  1, 0, -1, -1};
	static int [] len = new int[]{3,4,5,4,3};
	public static void main (String [] arg) {
		Scanner sc = new Scanner(System.in);

		boolean [][] state = new boolean [5][9];
		int cnt = 0;
		for (int i = 0; i<len.length; ++i) {
			int offset = (i % 2) + ((len[i] == 3) ? 2 : 0);
			for (int j = 0; j<len[i]; ++j) {
				String s = sc.next();
				state[i][offset+2*j] = (s.charAt(0) == '.') ? false : true;
				if (state[i][offset+2*j]) ++cnt;
			}
		}
		Arrays.fill(dp,-1);
		boolean who = canwin(state, cnt);
		System.out.println((who) ? "Karlsson" : "Lillebror");

	}
	public static boolean canwin (boolean [][] state, int left) {
		if (left <= 0) return false;
		int V = toInt(state);
		if (dp[V] >= 0) return (dp[V] != 0);

		boolean canwin = false;
		for (int i = 0; i<len.length; ++i) {
			for (int j = 0; j<state[i].length && !canwin; ++j) {
				if (!state[i][j]) continue;
				state[i][j] = false;
				canwin |= !canwin(state, left-1);
				for (int k = 0; k<dx.length; ++k) {
					for (int len = 1; ; ++len) {
						int i1 = dy[k]*len + i;
						int j1 = dx[k]*len + j;
						if (i1 < 0 || j1 < 0 || i1 >= state.length || j1 >= state[i].length || !state[i1][j1]) {
							while (len-- > 1) {
								i1 -= dy[k];
								j1 -= dx[k];
								state[i1][j1] = true;
							}
							break;
						}
						state[i1][j1] = false;
						canwin |= !canwin(state,left-len-1);
					}
				}
				state[i][j] = true;
			}
		}
		//System.out.println(toString(state) + " : " + canwin);
		dp[V] = (canwin) ? 1 : 0;
		return canwin;

	}
	public static String toString (boolean [][] state) {
		String s = "";
		for (int i = 0; i<state.length; ++i) {
			for (int j = 0; j<state[i].length; ++j) {
				s += (state[i][j]) ? "o" : ".";
			}
			s+="\n";
		}
		return s;
	}
	public static int toInt (boolean [][] state) {
		int cnt = 0;
		int ans = 0;
		for (int i = 0; i<len.length; ++i) {
			int offset = (i & 1) + ((len[i] == 3) ? 2 : 0);
			for (int j = 0; j<len[i]; ++j) {
				if (state[i][offset+2*j]) ans |= (1<<cnt);
				cnt++;
			}
		}
		return ans;
	}
}


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

public class Main {

	BufferedReader in;
	StringTokenizer str = null;
	PrintWriter out;

	private String next() throws Exception{
		while (str == null || !str.hasMoreElements())
			str = new StringTokenizer(in.readLine());
		return str.nextToken();
	}

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

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

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

	int []dp;
	int n = 5, m = 9;
	int []x,y;

	public void run() throws Exception{
		in =  new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		char [][]a = new char[n][];
		for(int i=0;i<n;i++) {
			// String x = in.readLine();
			// while(x.length() < m) x+=" ";
			a[i] = in.readLine().toCharArray();
		}

		x = new int[19];
		y = new int[19];
		int at = 0;
		for(int i=0;i<n;i++){
			for(int j=0;j<a[i].length;j++){
				if (a[i][j] != ' ') {
					x[at] = i;
					y[at++] = j;
				}
			}
		}

		// print(a);

		dp = new int[1 << 19];
		Arrays.fill(dp, -1);

		dp[262143]=1;
		dp[393215]=1;
		dp[458751]=1;
		dp[491519]=1;
		dp[507903]=1;
		dp[516095]=1;
		dp[520191]=1;
		dp[522239]=1;
		dp[523263]=1;
		dp[523775]=0;
		dp[524031]=1;
		dp[524159]=1;
		dp[524223]=1;
		dp[524255]=1;
		dp[524271]=1;
		dp[524279]=1;
		dp[524283]=1;
		dp[524285]=1;
		dp[524286]=1;
		dp[524287]=1;

		int mask = encode(a);
		// print(decode(mask));
		boolean r = dfs(mask);

		if (r) out.println("Karlsson");
		else out.println("Lillebror");
		// out.println("{");
		// for(int i=0;i<1<<19;i++){
		// 	if (Integer.bitCount(i) >= 18) {
		// 		if (dp[i] == -1) dfs(i);
		// 		out.println("dp["+i+"]="+dp[i]+";");
		// 	}
		// }
		// out.println("}");
		out.close();
	}

	int di[] = new int[]{0,  0, 1, -1, 1,  1, -1, -1};
	int dj[] = new int[]{2, -2, 0,  0, 1, -1, -1,  1};

	private boolean dfs(int mask) {
		if (mask == 0) return false;
		if (dp[mask] != -1) return dp[mask] > 0;

		// System.out.println(mask);

		char [][]a = decode(mask);
		char [][]b;
		for(int i=0;i<19;i++){
			if (a[x[i]][y[i]] == 'O') {
				for(int k=0;k<di.length;k++){
					int ni = x[i], nj = y[i];
					b = copy(a);
					while(inRange(ni, nj) && b[ni][nj] == 'O') {
						b[ni][nj] = '.';
						int nmask = encode(b);
						// System.out.println("from ");
						// print(a);
						// System.out.println("to ");
						// print(b);
						if (!dfs(nmask)) {
							dp[mask] = 1;
							return true;
						}
						ni+=di[k];
						nj+=dj[k];
					}
				}
			}
		}

		dp[mask] = 0;
		return false;
	}

	private boolean inRange(int i, int j) {
		if (i < 0 || j < 0) return false;
		if (i >= n || j >= m) return false;
		return true;
	}

	private void print(char [][]a) {
		for(int i=0;i<n;i++) System.out.println(Arrays.toString(a[i]));
		System.out.println();
	}

	private char[][] copy(char [][]a) {
		char [][]b = a.clone();
		for(int i=0;i<n;i++) {
			b[i] = b[i].clone();
		}
		return b;
	}

	private int encode(char [][]a) {
		int mask = 0;
		for(int i=0;i<19;i++){
			if (a[x[i]][y[i]] == 'O') {
				mask|=1<<i;
			}
		}
		return mask;
	}

	private char[][] decode(int mask) {
		char [][]r = new char[n][m];
		for(int i=0;i<19;i++){
			if ((mask & (1 << i)) > 0) {
				r[x[i]][y[i]] = 'O';
			}else {
				r[x[i]][y[i]] = '.';
			}
		}
		return r;
	}

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


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

public class BetaRound59_E implements Runnable {

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

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

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

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

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

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

	class State {
		int[] arr;
		State(int[] a) {
			arr = a;
		}
	}

	int[] getArray(List<Integer> list) {
		int[] ans = new int[list.size()];
		for (int i = 0; i < ans.length; i++) {
			ans[i] = list.get(i);
		}
		return ans;
	}

	List<State> getStates(int[] a) {
		List<State> ans = new ArrayList<State>();
		List<Integer> list = new ArrayList<Integer>();
		for (int from = 0; from < a.length; from++) {
			for (int to = from + 1; to < a.length; to++) {
				for (int k = from; k <= to; k++) {
					list.add(a[k]);
				}
				ans.add(new State(getArray(list)));
				list.clear();
			}
		}
		return ans;
	}

	int[] getPossibleMoveMasks() {
		final int[][] lines = {
				{1,2,3},
				{4,5,6,7},
				{8,9,10,11,12},
				{13,14,15,16},
				{17,18,19},

				{1,4,8},
				{2,5,9,13},
				{3,6,10,14,17},
				{7,11,15,18},
				{12,16,19},

				{8,13,17},
				{4,9,14,18},
				{1,5,10,15,19},
				{2,6,11,16},
				{3,7,12}
		};

		List<State> states = new ArrayList<State>();
		for (int i = 1; i <= 19; i++) {
			states.add(new State(new int[] {i}));
		}
		for (int i = 0; i < lines.length; i++) {
			List<State> list = getStates(lines[i]);
			states.addAll(list);
		}

		int[][] moves = new int[states.size()][];
		for (int i = 0; i < moves.length; i++) {
			moves[i] = states.get(i).arr;
		}

		int[] ans = new int[moves.length];
		for (int i = 0; i < moves.length; i++) {
			int p = 0;
			for (int j = 0; j < moves[i].length; j++) {
				p += (1 << (moves[i][j] - 1));
			}
			ans[i] = p;
		}
		Arrays.sort(ans);
		return ans;
	}

	final int[] moves = getPossibleMoveMasks();

	void solve() throws IOException {
		int start = 0;
		for (int i = 0; i < 19; i++) {
			String s = readString();
			if (s.equals("O")) {
				start += (1 << i);
			}
		}
		vis[0] = true;
		boolean ans = dfs(start);
		out.print(ans ? "Karlsson" : "Lillebror");
	}

	boolean[] d = new boolean[1 << 19];
	boolean[] vis = new boolean[1 << 19];

	boolean dfs(int from) {
		if (vis[from]) {
			return d[from];
		}
		boolean ans = false;
		for (int move : moves) {
			if ((from | move) == from) {
				ans |= !dfs(from ^ move);
			}
		}
		vis[from] = true;
		return d[from] = ans;
	}

}


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

public class SweetsGame {
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
		char[][] arr=new char[5][];
		int index=18;
		int mask=0;
		for (int i = 0; i < arr.length; i++) {
			String s=r.readLine().trim().replaceAll("[ ]+", "");

			arr[i]=s.toCharArray();
			for (int j = 0; j < arr[i].length; j++) {
				if(arr[i][j]=='O')
					mask|=(1<<index);
				index--;
			}

		}
		org=mask;
		String[] res= {"Karlsson","Lillebror"};
		System.out.println(res[go(mask,0)]);
		}
	static Integer[][] dp=new Integer[1<<19][2];
	static int org;
	public static char[][] encode(int mask){
		char[][] arr=new char[5][];
		arr[0]=new char[3];
		arr[1]=new char[4];
		arr[2]=new char[5];
		arr[3]=new char[4];
		arr[4]=new char[3];
		int x=0,y=0;
		for(int i=18;i>=0;i--){
			arr[x][y++]=(mask&1<<i)==(1<<i)?'o':'.';
			if(i==16){
				x++;
				y=0;
			}
			if(i==12){
				x++;
				y=0;
			}
			if(i==7){
				x++;
				y=0;
			}
			if(i==3){
				x++;
				y=0;
			}
		}
//		for (int i = 0; i < arr.length; i++) {
//			System.out.println(new String(arr[i]));
//		}
//		System.out.println();
		return arr;
	}
	public static int go(int mask,int turn){
		if(mask==0){
			return 1-turn;
		}
		if(dp[mask][turn]!=null)return dp[mask][turn];
		char[][]arr=encode(mask);
		for(int i=0;i<5;i++){
			for(int j=0;j<arr[i].length;j++){
				if(arr[i][j]=='o'){
					int newMask=mask;
					for(int k=j;k<arr[i].length;k++){
						if(arr[i][k]=='o'){
							int index=get(i,k);
							newMask&=(~(1<<index));
							if(go(newMask,1-turn)==turn){
								return dp[mask][turn]=turn;
							}
						}
						else break;
					}

						newMask=mask;
						int col=j;
						for(int k=i;k<arr.length;k++){
							if(col>=0&&col<arr[k].length&&arr[k][col]=='o'){
								int index=get(k,col);
								newMask&=(~(1<<index));
								if(go(newMask,1-turn)==turn){
									return dp[mask][turn]=turn;
								}
								if(k>=2)col--;
							}
							else break;
						}

						newMask=mask;
					newMask=mask;
					int r=i , c=j;
					while(true){
						if(r<arr.length&&c>=0&&c<arr[r].length&&arr[r][c]=='o'){
							int index=get(r,c);
							newMask&=(~(1<<index));
							if(go(newMask,1-turn)==turn){
								return dp[mask][turn]=turn;
							}
							r++;
							if(r>2);else
							c++;
						}
						else break;
					}
				}
			}
		}
		return dp[mask][turn]=1-turn;
	}
	private static int get(int i, int k) {
		int[][] arr={{18,17,16},{15,14,13,12},{11,10,9,8,7},{6,5,4,3},{2,1,0}};
		return arr[i][k];
	}

}


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

public class Main implements Runnable {
	StringTokenizer tokenizer = new StringTokenizer("");
	BufferedReader in;
	PrintStream out;

	int[] dm;
	int[] d = new int[1 << 19];
	int LEN = 47 * 6;

	public void debug(String s) {
		System.out.println(s);
	}

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

	int win(int msk) {
		if (d[msk] != -1) {
			return d[msk];
		}
		for (int i = 0; i < LEN; i++) {
			int rmsk = dm[i];
			if (((msk & rmsk) == rmsk) && win(msk & (~rmsk)) == 0)
				return d[msk] = 1;
		}
		return d[msk] = 0;
	}

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintStream(System.out);

			Arrays.fill(d, -1);
			d[0] = 0;

			dm = new int[LEN];

			int[][] a = new int[][] { new int[] { 0, 1, 2 },
					new int[] { 3, 4, 5, 6 }, new int[] { 7, 8, 9, 10, 11 },
					new int[] { 12, 13, 14, 15 }, new int[] { 16, 17, 18 } };
			int[] p = new int[19];

			p[0] = 2;
			p[2] = 11;
			p[11] = 18;
			p[18] = 16;
			p[16] = 7;
			p[7] = 0;

			p[9] = 9;

			p[4] = 5;
			p[5] = 10;
			p[10] = 14;
			p[14] = 13;
			p[13] = 8;
			p[8] = 4;

			p[1] = 6;
			p[6] = 15;
			p[15] = 17;
			p[17] = 12;
			p[12] = 3;
			p[3] = 1;

			int[][] w = new int[6][19];
			for (int i = 0; i < 19; i++)
				w[0][i] = i;
			for (int rot = 1; rot < 6; rot++) {
				for (int i = 0; i < 19; i++) {
					w[rot][i] = p[w[rot - 1][i]];
				}
			}

			int cnt = 0;
			for (int rot = 0; rot < 6; rot++) {
				for (int row = 0; row < 5; row++) {
					for (int l = 0; l < a[row].length; l++) {
						for (int r = l; r < a[row].length; r++) {
							int msk = 0;
							for (int t = l; t <= r; t++)
								msk |= (1 << w[rot][a[row][t]]);
							dm[cnt++] = msk;
						}
					}
				}
			}

			//for (int i = 0; i < dm.length; i++) out.println(dm[i]);

			int pos = 0;

			String s = "";
			for (int i = 0; i < 5; i++) s += in.readLine();
			s = s.replace(" ", "");
			//System.out.println(s);
			for (int i = 0; i < s.length(); i++) if (s.charAt(i) == 'O') pos |= (1 << i);

			out.println(win(pos) == 1 ? "Karlsson" : "Lillebror");

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	boolean seekForToken() {
		while (!tokenizer.hasMoreTokens()) {
			String s = null;
			try {
				s = in.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (s == null)
				return false;
			tokenizer = new StringTokenizer(s);
		}
		return true;
	}

	String nextToken() {
		return seekForToken() ? tokenizer.nextToken() : null;
	}

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

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

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

	BigInteger nextBig() {
		return new BigInteger(nextToken());
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class D {

	static ArrayList<Integer> cuts = new ArrayList<Integer>(102);

	static Boolean[] memo;

	static boolean win(int msk)
	{
		if(msk == 0)
			return false;
		if(memo[msk] != null)
			return memo[msk];
		boolean win = false;
		for(int cut: cuts)
			if((msk & cut) == cut)
				win |= !win(msk ^ cut);
		return memo[msk] = win;
	}

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

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

		for(int i = 0; i < 19; ++i)
			cuts.add(1<<i);
		int[][] a = {{0, 1, 2}, {3, 4, 5, 6}, {7, 8, 9, 10, 11}, {12, 13, 14, 15}, {16, 17, 18}};
		int[][] b = {{0, 3, 7}, {1, 4, 8, 12}, {2, 5, 9, 13, 16}, {6, 10, 14, 17}, {11, 15, 18}};
		int[][] c = {{2, 6, 11}, {1, 5, 10, 15}, {0, 4, 9, 14, 18}, {3, 8, 13, 17}, {7, 12, 16}};
		addCuts(cuts, a);
		addCuts(cuts, b);
		addCuts(cuts, c);

		int msk = 0;
		for(int i = 0; i < 19; ++i)
			if(sc.next().charAt(0) == 'O')
				msk |= 1<<i;
		memo = new Boolean[1<<19];
		out.println(win(msk)?"Karlsson":"Lillebror");
		out.flush();
		out.close();
	}

	static void addCuts(ArrayList<Integer> cuts, int[][] x)
	{
		for(int[] y: x)
			for(int len = 2; len <= y.length; ++len)
				for(int i = 0; i + len <= y.length; ++i)
				{
					int msk = 0;
					for(int j = i; j < i + len; ++j)
						msk |= 1<<y[j];
					cuts.add(msk);
				}
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

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

	}
}


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

public class E {

    int[][] f;
    int[] d;

    void solve() throws IOException {
        in("__std"); out("__std");

        f = new int[5][];
        int k = 0;
        for (int i = 0; i < 5; ++i) {
            char[] l = readLine().toCharArray();
            f[i] = new int[l.length];
            Arrays.fill(f[i], -1);
            for (int j = 0; j < l.length; ++j) {
                if (l[j] == 'O') {
                    f[i][j] = k++;
                }
            }
        }
        int c = 1 << k;
        d = new int[c];
        if (win(c - 1)) {
            println("Karlsson");
        } else {
            println("Lillebror");
        }

        exit();
    }

    boolean win(int c) {
        if (d[c] == 0) {
            int r = 2;
            for (int i = 0; i < 5 && r == 2; ++i) {
                for (int j = 0; j < f[i].length && r == 2; ++j) {
                    if (f[i][j] != -1 && (c & (1 << f[i][j])) != 0) {
                        //right
                        int cc = 0;
                        int ii = i;
                        int jj = j;
                        while (jj < f[ii].length && r == 2 && f[ii][jj] != -1 && (c & (1 << f[ii][jj])) != 0) {
                            cc |= 1 << f[ii][jj];
                            if (!win(c & (~cc))) r = 1;
                            jj += 2;
                        }
                        if (r == 2) {
                            //diag left
                            cc = 0;
                            ii = i;
                            jj = j;
                            while (ii < 5 && jj >= 0 && r == 2 && f[ii][jj] != -1 && (c & (1 << f[ii][jj])) != 0) {
                                cc |= 1 << f[ii][jj];
                                if (!win(c & (~cc))) r = 1;
                                ++ii;
                                --jj;
                            }
                            if (r == 2) {
                                //diag right
                                cc = 0;
                                ii = i;
                                jj = j;
                                while (ii < 5 && jj < f[ii].length && r == 2 && f[ii][jj] != -1 && (c & (1 << f[ii][jj])) != 0) {
                                    cc |= 1 << f[ii][jj];
                                    if (!win(c & (~cc))) r = 1;
                                    ++ii;
                                    ++jj;
                                }
                            }
                        }
                    }
                }
            }
            d[c] = r;
        }
        return d[c] == 1;
    }

    void in(String name) throws IOException {
        if (name.equals("__std")) {
            in = new BufferedReader(new InputStreamReader(System.in));
        } else {
            in = new BufferedReader(new FileReader(name));
        }
    }

    void out(String name) throws IOException {
        if (name.equals("__std")) {
            out = new PrintWriter(System.out);
        } else {
            out = new PrintWriter(name);
        }
    }

    void exit() {
        out.close();
        System.exit(0);
    }

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

    double readDouble() throws IOException {
        return Double.parseDouble(readToken());
    }

    String readLine() throws IOException {
        st = null;
        return in.readLine();
    }

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

    boolean eof() throws IOException {
        return !in.ready();
    }

    void print(String format, Object ... args) {
        out.println(new Formatter().format(format, args));
    }

    void println(String format, Object ... args) {
        out.println(new Formatter().format(format, args));
    }

    void print(Object value) {
        out.print(value);
    }

    void println(Object value) {
        out.println(value);
    }

    void println() {
        out.println();
    }

    StringTokenizer st;

    BufferedReader in;
    PrintWriter out;

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


import static java.util.Arrays.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import java.util.*;
import java.math.*;
import java.io.*;

public class E implements Runnable
{
    String file = "input";

    boolean TEST = false;

    int[] mapCoord = new int[100];
    int[] mapBit = new int[100];
    char[][] cs;
    int rn = 5, cn = 9;

    void solve() throws IOException
    {
        cs = new char[rn][cn];
        int num = 0, mask = 0;
        fill(mapCoord, -1);

        for(int i = 0; i < 5; i++)
        {
            cs[i] = input.readLine().toCharArray();
            //print(i, cs[i]);
            for(int j = abs(2 - i), count = 0; count < 5 - abs(2 - i); count++, j += 2)
            {
                if(cs[i][j] == 'O') mask |= 1 << num;
                mapCoord[i * cn + j] = num;
                mapBit[num] = i * cn + j;
                //print(i, j, num);
                num++;
            }
        }
        //print(num, mask, mapBit);
        calc = new boolean[1 << 19];
        win = new boolean[1 << 19];
        if(can(mask)) out.println("Karlsson");
        else out.println("Lillebror");
    }

    int[] dy = {-1, 1, 2, 1, -1, -2};
    int[] dx = {-1, -1, 0, 1, 1, 0};
    boolean[] calc, win;

    boolean can(int mask)
    {
        //print(mask);
        if(mask == 0) return false;

        if(calc[mask]) return win[mask];
        calc[mask] = true;

        for(int i = 0; i < 19; i++)
        {
            if((mask >> i & 1) == 0) continue;
            int cur = mask ^ (1 << i);
            if(!can(cur)) return win[mask] = true;

            for(int k = 0; k < 6; k++)
            {
                cur = mask ^ (1 << i);

                int x = mapBit[i] / cn;
                int y = mapBit[i] % cn;

                while(x + dx[k] >= 0 && x + dx[k] < rn && y + dy[k] >= 0 && y + dy[k] < cs[x + dx[k]].length)
                {
                    x += dx[k];
                    y += dy[k];

                    int j = mapCoord[x * cn + y];
                    if(j == - 1 || (cur >> j & 1) == 0) break;

                    cur ^= 1 << j;
                    if(!can(cur)) return win[mask] = true;
                }
            }
        }
        return win[mask] = false;
    }

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

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

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

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

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

    void gcj(Object o)
    {
        String s = String.valueOf(o);
        out.println("Case #" + test + ": " + s);
        System.out.println("Case #" + test + ": " + s);
    }

    BufferedReader input;
    PrintWriter out;
    StringTokenizer st;
    int test;

    void init() throws IOException
    {
        if(TEST) input = new BufferedReader(new FileReader(file + ".in"));
        else input = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new BufferedOutputStream(System.out));
    }

    public static void main(String[] args) throws IOException
    {
        new Thread(null, new E(), "", 1 << 22).start();
    }

    public void run()
    {
        try
        {
            init();
            if(TEST)
            {
                int runs = nextInt();
                for(int i = 0; i < runs; i++) solve();
            }
            else solve();
            out.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
            System.exit(1);
        }
    }
}


/**
 * Created by IntelliJ IDEA.
 * User: aircube
 * Date: 28.02.11
 * Time: 20:43
 * To change this template use File | Settings | File Templates.
 */

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

public class TaskD {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;

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

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

    int a[][] ;
    int dm[][];
    void solve() throws IOException {
        a = new int[15][];
        a[0] = new int[] {1, 2, 3};
        a[1] = new int[] {17, 18, 19};
        a[2] = new int[] {8, 13, 17};
        a[3] = new int[] {3, 7, 12};
        a[4] = new int[] {1, 4, 8};
        a[5] = new int[] {12, 16, 19};
        a[6] = new int[] {7, 11, 15, 18};
        a[7] = new int[] {2, 5, 9, 13};
        a[8] = new int[] {2, 6, 11, 16};
        a[9] = new int[] {13, 14, 15, 16};
        a[10] = new int[] {4, 9, 14, 18};
        a[11] = new int[] {4, 5, 6, 7};
        a[12] = new int[] {8, 9, 10, 11, 12};
        a[13] = new int[] {1, 5, 10, 15, 19};
        a[14] = new int[] {3, 6, 10, 14, 17};

        dm = new int[1 << 19][2];
        for (int i = 0; i < dm.length; ++i)
            dm[i][0] = dm[i][1] = -1;

        for (int i = 0; i < a.length; ++i)
            for (int j = 0; j < a[i].length; ++j)
                a[i][j] -- ;

        int mask = 0;
        for (int t = 0; t < 19; ++t) {
            String str = nextToken();
            if (str.compareTo("O") == 0) mask |= (1 << t) ;;
        }
        int res = brute(mask, 0);
        out.print(res == 1 ? "Karlsson" : "Lillebror");

    }
    int brute(int mask, int turn) {
        if (mask == 0) {
            return turn;
        }
        if (dm[mask][turn] != -1) return dm[mask][turn];
        if (dm[mask][turn ^ 1] != -1) return dm[mask][turn ^ 1] ^ 1;

        for(int v = 0; v < a.length; ++v) {

            for (int i = 0; i < a[v].length; ++i) {
                for(int j = i; j < a[v].length; ++j) {
                    boolean ok = true;
                    for (int u = i; ok && u <= j; ++u) {
                        if ((mask & (1 << a[v][u])) == 0) ok = false;
                    }
                    if (ok) {
                        for (int I = i; I <= j; ++I)
                            for(int J = I; J <= j; ++J) {
                                int cm = 0;
                                for (int k = I; k <= J; ++k) {
                                    cm |= (1 << a[v][k]);
                                }
                                int d = brute(mask ^ cm, turn ^ 1);
                                if (turn == 0 && d == 1)  return dm[mask][turn] = 1;
                                if (turn == 1 && d == 0) return dm[mask][turn] = 0;
                            }
                    }
                }
            }
        }

        return dm[mask][turn] = turn;
    }

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

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

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

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


import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class P063E {

	Scanner sc = new Scanner(System.in);

	int INF = 1 << 28;
	double EPS = 1e-9;

	int m = 19;
	int n = 5;
	int now;

	void run() {
		for (int i = 0; i < m; i++) {
			now |= sc.next().charAt(0) == 'O' ? (1 << i) : 0;
		}
		solve();
	}

	int[][] map;
	int[] x, y;

	int[] win;

	void solve() {
		map = new int[][] { { 0, 1, 2, -1, -1 }, { 3, 4, 5, 6, -1 },
				{ 7, 8, 9, 10, 11 }, { -1, 12, 13, 14, 15 },
				{ -1, -1, 16, 17, 18 } };
		x = new int[m];
		y = new int[m];
		for (int j = 0; j < n; j++) {
			for (int i = 0; i < n; i++) {
				if (map[j][i] != -1) {
					x[map[j][i]] = i;
					y[map[j][i]] = j;
				}
			}
		}

		win = new int[1 << m];
		fill(win, -1);

		dfs(now);

		// debug(win[now]);
		println(new String[] { "Lillebror", "Karlsson" }[win[now]]);
	}

	int[] dx = { 1, 0, 1 };
	int[] dy = { 0, 1, 1 };

	int dfs(int state) {
		if (win[state] >= 0) {
			return win[state];
		}
		if (state == 0) {
			return win[state] = 0;
		}
		for (int j = 0; j < n; j++) {
			for (int i = 0; i < n; i++) {
				for (int k = 0; k < 3; k++) {
					for (int x = i, y = j, bit = 0; x < n && y < n
							&& map[y][x] != -1 && (state >> map[y][x] & 1) == 1; x += dx[k], y += dy[k]) {
						bit |= 1 << map[y][x];
						if (dfs(state ^ bit) == 0) {
							win[state] = 1;
							return win[state];
						}
					}
				}
			}
		}
		return win[state] = 0;
	}

	void println(String s) {
		System.out.println(s);
	}

	void print(String s) {
		System.out.print(s);
	}

	void debug(Object... os) {
		System.err.println(deepToString(os));
	}

	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		new P063E().run();
	}

}


import java.util.*;

public class E {

    int p2[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024,
        2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144};

    boolean bitSetted(int code, int bitNo) {
        return (code & (1 << bitNo)) != 0;
    }

    int clearBit(int code, int bitNo) {
        return code - p2[bitNo];
    }

    public static void main(String[] args) {
        new E().main();
    }
    int[][] gameLines = {
        // horizontal
        {0, 1, 2},
        {3, 4, 5, 6},
        {7, 8, 9, 10, 11},
        {12, 13, 14, 15},
        {16, 17, 18},
        // /-diag
        {7, 3, 0},
        {12, 8, 4, 1},
        {16, 13, 9, 5, 2},
        {17, 14, 10, 6},
        {18, 15, 11},
        // \-diag
        {2, 6, 11},
        {1, 5, 10, 15},
        {0, 4, 9, 14, 18},
        {3, 8, 13, 17},
        {7, 12, 16}
    };
    int sg_values[] = new int[530000];

    boolean canDoMove(int position, int gameLineNo, int left, int right) {
        for (int i = left; i <= right; i++) {
            if (!bitSetted(position,gameLines[gameLineNo][i])) {
                return false;
            }
        }
        return true;
    }

    int doMove(int position, int gameLineNo, int left, int right) {
        int res = position;
        for (int i = left; i <= right; i++) {
            res = clearBit(res, gameLines[gameLineNo][i]);
        }
        return res;
    }

    ArrayList<Integer> inOneMove(Integer position) {
        ArrayList<Integer> res = new ArrayList<Integer>();

        for (int i = 0; i < gameLines.length; i++) {
            for (int left = 0; left < gameLines[i].length; left++) {
                for (int right = left; right < gameLines[i].length; right++) {
                    if (canDoMove(position, i, left, right)) {
                        res.add(doMove(position, i, left, right));
                    }
                }
            }
        }
        return res;
    }

    // false, если позиция проигрышная
    // true,  если выигрышная
    int SG(Integer position) {
        if (sg_values[position] != 0) {
            return sg_values[position];
        }
        //System.out.println("Calculating SG for " + position);
        int res = -1;
        for (int x : inOneMove(position)) {
            if (SG(x) == -1) {
                res = 1;
                break;
            }
        }
        sg_values[position] = res;
        return res;
    }

    void main() {
        String spos = "";
        Scanner in = new Scanner(System.in);
        for (int i = 0; i < 5; i++) {
            String line = in.nextLine();
            for (char c : line.toCharArray()) {
                if (c == '.' || c == 'O') {
                    spos += c;
                }
            }
        }
        int now = 0;
        for (int i = 0; i < spos.length(); i++) {
            if (spos.charAt(i) == 'O') {
                now += p2[i];
            }
        }
        sg_values[0] = -1;
        if (SG(now) == -1) {
            System.out.println("Lillebror");
        } else {
            System.out.println("Karlsson");
        }
    }
}


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

public class Igraskonfetami {
	static BufferedReader br = new BufferedReader(new InputStreamReader(
			System.in));

	static StringTokenizer in;

	static PrintWriter out = new PrintWriter(System.out);

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

		return in.nextToken();
	}

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

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

	static int[][] pos = new int[][] { { 0, 0, 1, 0, 2, 0, 3, 0, 0 },
			{ 0, 4, 0, 5, 0, 6, 0, 7, 0 }, { 8, 0, 9, 0, 10, 0, 11, 0, 12 },
			{ 0, 13, 0, 14, 0, 15, 0, 16, 0 }, { 0, 0, 17, 0, 18, 0, 19, 0, 0 } };

	static int[][] sweet = new int[][] { { 0, 2 }, { 0, 4 }, { 0, 6 },
			{ 1, 1 }, { 1, 3 }, { 1, 5 }, { 1, 7 }, { 2, 0 }, { 2, 2 },
			{ 2, 4 }, { 2, 6 }, { 2, 8 }, { 3, 1 }, { 3, 3 }, { 3, 5 },
			{ 3, 7 }, { 4, 2 }, { 4, 4 }, { 4, 6 } };

	static boolean[] ans;

	public static int get(boolean[][] c) {
		int mask = 0;
		for (int i = 0; i < c.length; i++) {
			for (int j = 0; j < c[0].length; j++) {
				if (c[i][j])
					mask += (1 << (pos[i][j] - 1));
			}
		}

		return mask;
	}

	static boolean win(int mask) {
		boolean[][] state = new boolean[5][9];

		for (int i = 0; i < 19; i++) {
			if ((mask & (1 << i)) > 0)
				state[sweet[i][0]][sweet[i][1]] = true;
		}

		boolean win = false;
		for (int i = 0; i < 19; i++) {
			int x = sweet[i][0];
			int y = sweet[i][1];

			if (!state[x][y])
				continue;

			// left
			int m = mask;
			for (int j = y; j < 9 && state[x][j]; j += 2) {
				m -= (1 << (pos[x][j] - 1));
				win = win | !ans[m];
				if (win)
					break;
			}

			// leftdiag
			m = mask;
			for (int k = x, j = y; k < 5 && j >= 0 && state[k][j]; k++, j--) {
				m -= (1 << (pos[k][j] - 1));
				win = win | !ans[m];
				if (win)
					break;
			}

			// rightdiag
			m = mask;
			for (int k = x, j = y; k < 5 && j < 9 && state[k][j]; k++, j++) {
				m -= (1 << (pos[k][j] - 1));

				win = win | !ans[m];
				if (win)
					break;
			}

			if (win)
				break;
		}

		return win;
	}

	public static void main(String[] args) throws IOException {
		ans = new boolean[1 << 19];

		ans[0] = false;

		for (int i = 1; i < ans.length; i++) {
			if (i == 281){
				int k = 0;
				k++;
			}

			ans[i] = win(i);
		}

		boolean[][] state = new boolean[5][9];

		for (int i = 0; i < state.length; i++) {
			String S = br.readLine();

			for (int j = 0; j < S.length(); j++) {
				if (S.charAt(j) == 'O')
					state[i][j] = true;
			}
		}

		int mask = get(state);

		if (ans[mask])
			System.out.println("Karlsson");
		else
			System.out.println("Lillebror");

		out.close();
	}
}


/**
 * Created by IntelliJ IDEA.
 * User: aircube
 * Date: 28.02.11
 * Time: 20:43
 * To change this template use File | Settings | File Templates.
 */

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

public class TaskD {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;

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

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

    int a[][] ;
    int dm[];
    void solve() throws IOException {
        a = new int[15][];
        a[0] = new int[] {1, 2, 3};
        a[1] = new int[] {17, 18, 19};
        a[2] = new int[] {8, 13, 17};
        a[3] = new int[] {3, 7, 12};
        a[4] = new int[] {1, 4, 8};
        a[5] = new int[] {12, 16, 19};
        a[6] = new int[] {7, 11, 15, 18};
        a[7] = new int[] {2, 5, 9, 13};
        a[8] = new int[] {2, 6, 11, 16};
        a[9] = new int[] {13, 14, 15, 16};
        a[10] = new int[] {4, 9, 14, 18};
        a[11] = new int[] {4, 5, 6, 7};
        a[12] = new int[] {8, 9, 10, 11, 12};
        a[13] = new int[] {1, 5, 10, 15, 19};
        a[14] = new int[] {3, 6, 10, 14, 17};

        dm = new int[1 << 19];
        Arrays.fill(dm, -1);

        for (int i = 0; i < a.length; ++i)
            for (int j = 0; j < a[i].length; ++j)
                a[i][j] -- ;

        int mask = 0;
        for (int t = 0; t < 19; ++t) {
            String str = nextToken();
            if (str.compareTo("O") == 0) mask |= (1 << t) ;;
        }
        int res = brute(mask);
        out.print(res == 1 ? "Karlsson" : "Lillebror");

    }
    int brute(int mask) {
        if (mask == 0) {
            return 0;
        }
        if (dm[mask] != -1) return dm[mask];

        for(int v = 0; v < a.length; ++v) {

            for (int i = 0; i < a[v].length; ++i) {
                for(int j = i; j < a[v].length; ++j) {
                    boolean ok = true;
                    for (int u = i; ok && u <= j; ++u) {
                        if ((mask & (1 << a[v][u])) == 0) ok = false;
                    }
                    if (ok) {
                        for (int I = i; I <= j; ++I)
                            for(int J = I; J <= j; ++J) {
                                int cm = 0;
                                for (int k = I; k <= J; ++k) {
                                    cm |= (1 << a[v][k]);
                                }
                                int d = brute(mask ^ cm);
                                if (d == 0) return dm[mask] = 1;
                            }
                    }
                }
            }
        }
        return dm[mask] = 0;
    }

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

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

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

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


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

public class E {
	int[]len=new int[]{3,4,5,4,3};
	int[][]getGet;
	boolean[]cached;
	boolean[]answer;
	void solve() throws Exception {
		cached=new boolean[1<<19];
		answer=new boolean[1<<19];
		getGet=new int[5][5];
		for(int r=0;r<5;r++)
			for(int c=0;c<5;c++)
				getGet[r][c]=get(r,c);
		int set=0;
		for(int r=0;r<5;r++)
		{
			String s=nextLine();
			s=s.replaceAll(" ", "");
			for(int j=0;j<len[r];j++)
				if((s.charAt(j))=='O')
					set|=1<<get(r,j);
		}
		if(rec(set))
			System.out.println("Karlsson");
		else
			System.out.println("Lillebror");
	}
	boolean rec(int set)
	{
		if(cached[set])
			return answer[set];
		boolean res=false;
		for(int r=0;r<5;r++)
			for(int c=0;c<len[r];c++)
			{
				int num=get(r,c);
				if((set&(1<<num))>0)
				{
					int cr=r;
					int cc=c;
					int cset=set;
					while(cr>=0 && cr<5 && cc>=0 && cc<len[cr] && (cset&(1<<getGet[cr][cc]))>0)
					{
						cset^=(1<<getGet[cr][cc]);
						res|=!rec(cset);
						cc++;
					}
					cr=r;
					cc=c;
					cset=set;
					while(cr>=0 && cr<5 && cc>=0 && cc<len[cr] && (cset&(1<<getGet[cr][cc]))>0)
					{
						cset^=(1<<getGet[cr][cc]);
						res|=!rec(cset);
						if(cr==2 || cr==3)
							cc--;
						cr++;
					}
					cr=r;
					cc=c;
					cset=set;
					while(cr>=0 && cr<5 && cc>=0 && cc<len[cr] && (cset&(1<<getGet[cr][cc]))>0)
					{
						cset^=(1<<getGet[cr][cc]);
						res|=!rec(cset);
						if(cr==0 || cr==1)
							cc++;
						cr++;
					}

				}
			}
		cached[set]=true;
		answer[set]=res;
		return res;

	}
	int get(int r,int c)
	{
		int res=0;
		for(int i=0;i<r;i++)
			res+=len[i];
		return res+c;
	}

	BufferedReader reader;
	PrintWriter writer;
	StringTokenizer stk;

	void run() throws Exception {
		reader = new BufferedReader(new InputStreamReader(System.in));
		stk = null;
		writer = new PrintWriter(System.out);
		solve();
		reader.close();
		writer.close();
	}

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

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

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

	String nextString() throws Exception {
		return nextToken();
	}

	String nextLine() throws Exception {
		return reader.readLine();
	}

	String nextToken() throws Exception {
		if (stk == null || !stk.hasMoreTokens()) {
			stk = new StringTokenizer(nextLine());
			return nextToken();
		}
		return stk.nextToken();
	}

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

}


import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Sweets Game
// 2012/11/03
public class P063E{
	Scanner sc=new Scanner(System.in);

	int m=19, n=5;
	int now;

	void run(){
		for(int i=0; i<m; i++){
			now|=sc.next().charAt(0)=='O'?(1<<i):0;
		}
		solve();
	}

	int[][] map;
	int[] win;

	void solve(){
		map=new int[][]{{0, 1, 2, -1, -1}, {3, 4, 5, 6, -1}, {7, 8, 9, 10, 11},
				{-1, 12, 13, 14, 15}, {-1, -1, 16, 17, 18}};
		win=new int[1<<m];
		fill(win, -1);
		println(new String[]{"Lillebror", "Karlsson"}[dfs(now)]);
	}

	int[] dx={1, 0, 1};
	int[] dy={0, 1, 1};

	int dfs(int state){
		if(win[state]>=0){
			return win[state];
		}
		if(state==0){
			return win[state]=0;
		}
		for(int j=0; j<n; j++){
			for(int i=0; i<n; i++){
				for(int k=0; k<3; k++){
					for(int x=i, y=j, bit=0; x<n&&y<n&&map[y][x]!=-1
							&&(state>>map[y][x]&1)==1; x+=dx[k], y+=dy[k]){
						bit|=1<<map[y][x];
						if(dfs(state^bit)==0){
							win[state]=1;
							return win[state];
						}
					}
				}
			}
		}
		return win[state]=0;
	}

	void println(String s){
		System.out.println(s);
	}

	void print(String s){
		System.out.print(s);
	}

	public static void main(String[] args){
		Locale.setDefault(Locale.US);
		new P063E().run();
	}
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Queue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Solution implements Runnable {

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

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;

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

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

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

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

    int[][] a = new int[5][5];

    void uncode(int q) {
        int t = 24;
        for (int i = 0; i < 19; i++) {
            while (a[t / 5][t % 5] == -1) t--;
            a[t / 5][t % 5] = q % 2;
            t--; q /= 2;
        }
    }

    int code() {
        int t = 0;
        int res = 0;
        for (int i = 0; i < 19; i++) {
            while (a[t / 5][t % 5] == -1) t++;
            res *= 2;
            res += a[t / 5][t % 5];
            t++;
        }
        return res;
    }

    void clone(int[][] a, int[][] b) {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                b[i][j] = a[i][j];
            }
        }
    }

    int[] ans = new int[1000000];

    boolean valid(int q) {
        if (q == 0) return false;
        while (q % 2 == 0) q /= 2;
        return (q & (q - 1)) == 0;
    }

    boolean rek(int q) {
        if (ans[q] != -1) return ans[q] == 1;
        boolean f = false;
        for (int i = 0; i < tl; i++) {
            if ((q | turn[i]) == q) {
                f |= !rek(q ^ turn[i]);
            }
        }
        ans[q] = f? 1 : 0;
        return f;
    }

    int[] turn = new int[25 * 25 * 25];
    int tl = 0;

    void solve() throws Exception {
        Arrays.fill(ans, -1);
        a[0][3] = a[0][4] = a[1][4] = -1;
        a[4][0] = a[4][1] = a[3][0] = -1;
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                for (int k = 0; i + k < 5 && a[i + k][j] != -1; k++) {
                    int[][] b = new int[5][5];
                    clone(a, b);
                    for (int kk = 0; kk <= k; kk++) a[i + kk][j] = 1;
                    turn[tl++] = code();
                    clone(b, a);
                }
                for (int k = 0; j + k < 5 && a[i][j + k] != -1; k++) {
                    int[][] b = new int[5][5];
                    clone(a, b);
                    for (int kk = 0; kk <= k; kk++) a[i][j + kk] = 1;
                    turn[tl++] = code();
                    clone(b, a);
                }
                for (int k = 0; i + k < 5 && j + k < 5 && a[i + k][j + k] != -1; k++) {
                    int[][] b = new int[5][5];
                    clone(a, b);
                    for (int kk = 0; kk <= k; kk++) a[i + kk][j + kk] = 1;
                    turn[tl++] = code();
                    clone(b, a);
                }
            }
        }
        Arrays.sort(turn, 0, tl);
        int ii = 1;
        for (int i = 1; i < tl; i++) {
            if (turn[i] != turn[i - 1]) turn[ii++] = turn[i];
        }
        tl = ii;
        int res = 0;
        for (int i = 0; i < 19; i++) {
            res *= 2;
            if (nextToken().charAt(0) != '.') res++;
        }
        if (rek(res)) out.println("Karlsson"); else out.println("Lillebror");
    }

    public void run() {
        Locale.setDefault(Locale.UK);
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        } finally {
            out.flush();
        }
    }

}


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

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

    int[] dp = new int[1<<19];
    final int[] dh = new int[]{0, 3, 7, 12, 16};
    final int[] dw = new int[]{3, 4, 5, 4, 3};
    boolean firstWin(int mask){
        if(dp[mask] != 0)return dp[mask] == 1;
        boolean ok = true;
        loop:
        for(int i = 0; i < 5; i++){
            for(int j = 0; j < dw[i]; j++){
                int k = dh[i] + j;
                if(((mask >> k) & 1) == 0)continue;
                int v = mask;
                int cy = i, cx = j;
                for(;;){
                    int ind = dh[cy] + cx;
                    v -= 1 << ind;
                    boolean ret = firstWin(v);
                    if(!ret){
                        ok = false;
                        break loop;
                    }
                    cy++;
                    if(cy > 2)cx--;
                    if(cy >= 5 || cx < 0 || cx >= dw[cy] || ((v >> (dh[cy] + cx)) & 1) == 0)break;
                }

                cy = i; cx = j;
                v = mask - (1 << (dh[cy] + cx));
                for(;;){
                    cy++;
                    if(cy < 3)cx++;
                    if(cy >= 5 || cx < 0 || cx >= dw[cy] || ((v >> (dh[cy] + cx)) & 1) == 0)break;
                    int ind = dh[cy] + cx;
                    v -= 1 << ind;
                    boolean ret = firstWin(v);
                    if(!ret){
                        ok = false;
                        break loop;
                    }
                }

                cy = i; cx = j;
                v = mask - (1 << (dh[cy] + cx));
                for(;;){
                    cx++;
                    if(cy >= 5 || cx < 0 || cx >= dw[cy] || ((v >> (dh[cy] + cx)) & 1) == 0)break;
                    int ind = dh[cy] + cx;
                    v -= 1 << ind;
                    boolean ret = firstWin(v);
                    if(!ret){
                        ok = false;
                        break loop;
                    }
                }

            }
        }
        if(ok){
            dp[mask] = -1;
            return false;
        }else{
            dp[mask] = 1;
            return true;
        }
    }

    int toi(boolean[] u){
        int ret = 0;
        for(int i = 0; i < u.length; i++)if(u[i])ret += 1 << i;
        return ret;
    }

    void run() throws Exception{
        Scanner sc = new Scanner(System.in);
        //BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
        // only sc.readLine() is available
        boolean[] u = new boolean[19];
        for(int i = 0; i < 19; i++)u[i] = sc.next().equals("O");
        boolean ret = firstWin(toi(u));
        System.out.println(ret ? "Karlsson" : "Lillebror");
    }
}


import java.util.*;

public class SweetsGame {
	static int[] memo;
	static int[] sj = new int[]{0,0,0,1,2};
	static int[] dj = new int[]{3,4,5,5,5};
	static int[] dx = new int[]{0,1,1};
	static int[] dy = new int[]{1,1,0};
	public static void main(String[] args){
		Scanner reader = new Scanner(System.in);
		int[][] d = new int[5][5];
		for(int i = 0; i < 5; i++){
			for(int j = sj[i]; j < dj[i]; j++){
				d[i][j] = reader.next().equals(".")?0:1;
			}
		}

		memo = new int[(1<<19)];
		System.out.println(f(e(d))>0?"Karlsson":"Lillebror");
	}

	public static void print(int n, int[][] d){
		System.out.println("At " + n + ", processing " + e(d));
		for(int i = 0; i < 5; i++)
			System.out.println(Arrays.toString(d[i]));
	}

	public static int f(int n){
		//System.out.println(Integer.toString(n,2));
		if(memo[n] == 0){
			if(n == 0){
				memo[n] = -1;
			}else{
				int[][] d = d(n);
				int canwin = -1;
//				print(n, d);
				for(int i = 0; i < 5 && canwin < 0; i++){
					for(int j = sj[i]; j < dj[i] && canwin < 0; j++){
						//Proceed in each direction
						for(int k = 0; k < 3 && canwin < 0; k++){
							int L = 0;
							while(nx(i,k,L) >= 0 && nx(i,k,L) < 5 && ny(j,k,L) >= sj[nx(i,k,L)] && ny(j,k,L) < dj[nx(i,k,L)] && d[nx(i,k,L)][ny(j,k,L)] > 0 && canwin < 0){
								//System.out.println("Killing " + i + " " + j + " " + L + " from " + " " + n);
								d[nx(i,k,L)][ny(j,k,L)] = 0;
//								print(n, d);
								canwin = Math.max(canwin, -f(e(d)));
								L++;
							}

							//Reset bitmask
							for(int z = 0; z < L; z++)
								d[nx(i,k,z)][ny(j,k,z)] = 1;
						}
					}
				}

				memo[n] = canwin;
			}
		}
//		System.out.println(n + " " + memo[n]);
		return memo[n];
	}

	public static int nx(int i, int k, int L){
		return i + dx[k]*L;
	}

	public static int ny(int j, int k, int L){
		return j + dy[k]*L;
	}

	public static int[][] d(int e){
		int[][] d = new int[5][5];

		for(int i = 4; i >= 0; i--){
			for(int j = dj[i]-1; j >= sj[i]; j--){
				d[i][j] = (e&1);
				e >>= 1;
			}
		}

		return d;
	}

	public static int e(int[][] d){
		int e = 0;
		for(int i = 0; i < 5; i++){
			for(int j = sj[i]; j < dj[i]; j++){
				e <<= 1;
				e |= d[i][j];
			}
		}
		return e;
	}
}


/**
 * Created by IntelliJ IDEA.
 * User: aircube
 * Date: 28.02.11
 * Time: 20:43
 * To change this template use File | Settings | File Templates.
 */

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

public class TaskD {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;

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

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

    int a[][] ;
    int dm[][];
    void solve() throws IOException {
        a = new int[15][];
        a[0] = new int[] {1, 2, 3};
        a[1] = new int[] {4, 5, 6, 7};
        a[2] = new int[] {8, 9, 10, 11, 12};
        a[3] = new int[] {13, 14, 15, 16};
        a[4] = new int[] {17, 18, 19};
        a[5] = new int[] {8, 13, 17};
        a[6] = new int[] {4, 9, 14, 18};
        a[7] = new int[] {1, 5, 10, 15, 19};
        a[8] = new int[] {2, 6, 11, 16};
        a[9] = new int[] {3, 7, 12};
        a[10] = new int[] {1, 4, 8};
        a[11] = new int[] {2, 5, 9, 13};
        a[12] = new int[] {3, 6, 10, 14, 17};
        a[13] = new int[] {7, 11, 15, 18};
        a[14] = new int[] {12, 16, 19};

        dm = new int[1 << 19][2];
        for (int i = 0; i < dm.length; ++i)
            dm[i][0] = dm[i][1] = -1;

        for (int i = 0; i < a.length; ++i)
            for (int j = 0; j < a[i].length; ++j)
                a[i][j] -- ;

        int mask = 0;
        for (int t = 0; t < 19; ++t) {
            String str = nextToken();
            if (str.compareTo("O") == 0) mask |= (1 << t) ;;
        }
        int res = brute(mask, 0);
        out.print(res == 1 ? "Karlsson" : "Lillebror");

    }
    int brute(int mask, int turn) {
        if (mask == 0) {
            return turn;
        }
        if (dm[mask][turn] != -1) return dm[mask][turn];

        for(int v = 0; v < a.length; ++v) {

            for (int i = 0; i < a[v].length; ++i) {
                for(int j = i; j < a[v].length; ++j) {
                    boolean ok = true;
                    for (int u = i; ok && u <= j; ++u) {
                        if ((mask & (1 << a[v][u])) == 0) ok = false;
                    }
                    if (ok) {
                        for (int I = i; I <= j; ++I)
                            for(int J = I; J <= j; ++J) {
                                int cm = 0;
                                for (int k = I; k <= J; ++k) {
                                    cm |= (1 << a[v][k]);
                                }
                                int d = brute(mask ^ cm, turn ^ 1);
                                if (turn == 0 && d == 1)  return dm[mask][turn] = 1;
                                if (turn == 1 && d == 0) return dm[mask][turn] = 0;
                            }
                    }
                }
            }
        }

        return dm[mask][turn] = turn;
    }

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

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

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

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


/**
 * Created by IntelliJ IDEA.
 * User: Taras_Brzezinsky
 * Date: 8/24/11
 * Time: 8:54 PM
 * To change this template use File | Settings | File Templates.
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.FileReader;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.Arrays;

public class TaskD extends Thread {

    public TaskD() {
        this.input = new BufferedReader(new InputStreamReader(System.in));
        this.output = new PrintWriter(System.out);
        this.setPriority(Thread.MAX_PRIORITY);
    }

    static class Matrix {
        long[][] grid;
        long[][] helper;

        public Matrix(int size, boolean E) {
            this.grid = new long[size][size];
            this.helper = new long[size][size];
            if (E) {
                for (int i = 0; i < grid.length; ++i) {
                    grid[i][i] = 1;
                }
            }
        }

        public Matrix pow(long power) {
            Matrix result = new Matrix(grid.length, true);
            Matrix stat = new Matrix(grid.length, false);
            for (int i = 0; i < grid.length; ++i) {
                stat.grid[i] = this.grid[i].clone();
            }
            while (power != 0) {
                if ((power & 1) == 1) {
                    result.multiply(stat);
                    --power;
                } else {
                    stat.multiply(stat);
                    power >>= 1;
                }
            }
            return result;
        }

        private void multiply(Matrix another) {
            for (long[] current : helper) {
                Arrays.fill(current, 0);
            }
            for (int i = 0; i < grid.length; ++i) {
                for (int j = 0; j < grid.length; ++j) {
                    for (int k = 0; k < grid.length; ++k) {
                        helper[i][j] += (grid[i][k] * another.grid[k][j]) % MODULO;
                    }
                    helper[i][j] %= MODULO;
                }
            }
            for (int i = 0; i < grid.length; ++i) {
                System.arraycopy(helper[i], 0, grid[i], 0, grid.length);
            }
        }
    }

    static class Rule {
        char letter;
        char value;

        public Rule(char letter, char value) {
            this.letter = letter;
            this.value = value;
        }
    }

    private void generate(int index) {
        if (index == initial.length) {
            states[SIZE++] = initial.clone();
        } else {
            for (char value = 0; value < rules[index].value; ++value) {
                initial[index] = value;
                generate(index + 1);
            }
        }
    }

    private boolean isFinal(int index) {
        for (char letter = 'A'; letter <= 'Z'; ++letter) {
            boolean was = false, isGood = false;
            for (int i = 0; i < rules.length; ++i) {
                if (rules[i].letter == letter) {
                    was = true;
                    isGood |= states[index][i] == 0;
                }
            }
            if (was && !isGood) {
                return false;
            }
        }
        return true;
    }

    private void solve() throws Throwable {
        long n = nextLong();
        int c = nextInt();
        int s = c;
        c = 0;
        rules = new Rule[s];
        int total = 1;
        for (int i = 0; i < s; ++ i) {
            rules[c] = new Rule(nextToken().charAt(0), (char) (nextInt()));
            boolean was = false;
            for (int q = 0; q < c; ++q) {
                if (rules[q].letter == rules[c].letter && rules[q].value == rules[c].value) {
                    was = true;
                    break;
                }
            }
            if (!was){
                total *= rules[c++].value;
            }
        }
        rules = Arrays.copyOf(rules, c);
        initial = new char[c];
        states = new char[total][];
        generate(0);
        Matrix operator = new Matrix(total, false);
        for (int from = 0; from < total; ++from) {
            for (char letter = 'A'; letter <= 'Z'; ++letter) {
                boolean isPresent = false;
                char []helper = states[from].clone();
                for (int i = 0; i < c; ++i) {
                    if (rules[i].letter == letter) {
                        isPresent = true;
                        helper[i] = (char)((helper[i] + 1) % rules[i].value);
                    }
                }
                if (isPresent) {
                    for (int to = 0; to < states.length; ++to) {
                        boolean ok = true;
                        for (int index = 0; index < c; ++index) {
                            ok &= states[to][index] == helper[index];
                        }
                        if (ok) {
                            operator.grid[from][to]++;
                            break;
                        }
                    }
                }
            }
        }

        Matrix finish = operator.pow(n);
        long result = 0;
        for (int current = 0; current < total; ++current) {
            if (isFinal(current)) {
                result = (result + finish.grid[0][current]) % MODULO;
            }
        }
        output.println(result);
    }

    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }

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

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

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

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

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

    private int SIZE = 0;
    private static final int MODULO = 12345;
    private char[][] states;
    private char[] initial;
    private Rule[] rules;
    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}


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

public class cfRound83_D {

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

    final int MOD = 12345;

    int[][] mul(int[][] a, int[][] b) {
        int[][] res = new int[sz][sz];
        for (int i = 0; i < sz; i++)
            for (int j = 0; j < sz; j++)
                for (int k = 0; k < sz; k++) {
                    res[i][j] += a[i][k] * b[k][j];
                    res[i][j] %= MOD;
                }

        return res;
    }

    int[][] power(int[][] a, long b) {
        if (b == 0) {
            int[][] res = new int[sz][sz];
            for (int i = 0; i < sz; i++)
                res[i][i] = 1;
            return res;
        }

        if ((b & 1) == 1)
            return mul(a, power(a, b - 1));

        int[][] tmp = power(a, b >> 1);
            return mul(tmp, tmp);

    }

    int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    int lcm(int a, int b) {
        if (a == 0)
            return b;
        if (b == 0)
            return a;

        return a / gcd(a, b) * b;
    }

    int sz;

    void solve() throws IOException {
        long n = nextLong();

        ArrayList<Integer>[] list = new ArrayList[26];
        for (int i = 0; i < 26; i++)
            list[i] = new ArrayList<Integer>();

        int c = nextInt();

        for (int i = 0; i < c; i++) {
            String s = nextToken();
            int x = nextInt();
            list[s.charAt(0) - 'A'].add(x);
        }

        ArrayList<Integer> can = new ArrayList<Integer>();
        ArrayList<Integer> mult = new ArrayList<Integer>();
        ArrayList<Integer> lcm = new ArrayList<Integer>();

        sz = 1;

        for (int i = 0; i < 26; i++)
            if (!list[i].isEmpty()) {
                int curLcm = 0;
                for (int x : list[i])
                    curLcm = lcm(curLcm, x);
                can.add(i);
                mult.add(sz);
                sz *= curLcm;
                lcm.add(curLcm);
            }

        mult.add(sz);

//      System.err.println(can);
//      System.err.println(mult);
//      System.err.println(lcm);

        int[][] matr = new int[sz][sz];

        for (int i = 0; i < sz; i++) {
            for (int j = 0; j < can.size(); j++) {
                int oldRem = i % mult.get(j + 1) / mult.get(j);
                int newRem = (oldRem + 1) % lcm.get(j);
                matr[i - oldRem * mult.get(j) + newRem * mult.get(j)][i]++;
            }
        }

        matr = power(matr, n);

        int ans = 0;

        for (int i = 0; i < sz; i++) {
            boolean goodTotalRem = true;
            for (int j = 0; j < can.size(); j++) {
                int curRem = i % mult.get(j + 1) / mult.get(j);
                boolean goodRem = false;
                for (int good : list[can.get(j)])
                    if (curRem % good == 0) {
                        goodRem = true;
                        break;
                    }
                if (!goodRem) {
                    goodTotalRem = false;
                    break;
                }
            }
            if (goodTotalRem) {
                ans += matr[i][0];
                if (ans >= MOD)
                    ans -= MOD;
            }
        }

        out.println(ans);
    }

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

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

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

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

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

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

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