using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;

class Solver
{
    public Scanner sc;
    public void Solve()
    {
        N = sc.Int;
        var A = new int[N][];
        var R = new int[N * N+1];R[N * N] = -1;
        for (int i = 0; i < N; i++)
        {
            A[i] = sc.ArrInt;
            for (int j = 0; j < N; j++)
            {
                A[i][j]--;
                R[A[i][j]] = Id(i, j);
            }
        }
        //dist:=iにいて，jまでクリアしていて，駒が0:knight,1:bishop,2:rookのとき
        var dist = Create(N * N, () => Create(N * N, () => Create(3, () => long.MaxValue / 2)));
        var pq = new PriorityQueue<(long c, int now, int cl, int pi)>((a, b) => a.c.CompareTo(b.c));
        dist[R[0]][0][0] = dist[R[0]][0][1] = dist[R[0]][0][2] = 0;
        pq.Push((0, R[0], 0, 0));
        pq.Push((0, R[0], 0, 1));
        pq.Push((0, R[0], 0, 2));
        while (pq.Any())
        {
            var (cst, now, cl, pi) = pq.Pop();
            int h = now / N, w = now % N;
            if (pi == 0)
            {
                for(int k = 0; k < knH.Length; k++)
                {
                    int nh = h + knH[k], nw = w + knW[k];
                    if (!Inside(nh, nw, N, N)) continue;
                    var p = cl;
                    if (Id(nh, nw) == R[cl + 1]) p++;
                    if (chmin(ref dist[Id(nh, nw)][p][pi], cst + W))
                    {
                        pq.Push((cst + W, Id(nh, nw), p, pi));
                    }
                }
            }
            else if (pi == 1)
            {
                for(int i = -N + 1; i <= N - 1; i++)
                {
                    {
                        int nh = i + h, nw = i + w;
                        if (!Inside(nh, nw, N, N)) goto SEC;
                        var p = cl;
                        if (Id(nh, nw) == R[cl + 1]) p++;
                        if (chmin(ref dist[Id(nh, nw)][p][pi], cst + W))
                        {
                            pq.Push((cst + W, Id(nh, nw), p, pi));
                        }
                    }
                SEC:;
                    {
                        int nh = i + h, nw = -i + w;
                        if (!Inside(nh, nw, N, N)) continue;
                        var p = cl;
                        if (Id(nh, nw) == R[cl + 1]) p++;
                        if (chmin(ref dist[Id(nh, nw)][p][pi], cst + W))
                        {
                            pq.Push((cst + W, Id(nh, nw), p, pi));
                        }
                    }
                }
            }
            else
            {
                for(int i = -N + 1; i <= N - 1; i++)
                {

                    {
                        int nh = h, nw = i + w;
                        if (!Inside(nh, nw, N, N)) goto SEC;
                        var p = cl;
                        if (Id(nh, nw) == R[cl + 1]) p++;
                        if (chmin(ref dist[Id(nh, nw)][p][pi], cst + W))
                        {
                            pq.Push((cst + W, Id(nh, nw), p, pi));
                        }
                    }
                SEC:;
                    {
                        int nh = i + h, nw = w;
                        if (!Inside(nh, nw, N, N)) continue;
                        var p = cl;
                        if (Id(nh, nw) == R[cl + 1]) p++;
                        if (chmin(ref dist[Id(nh, nw)][p][pi], cst + W))
                        {
                            pq.Push((cst + W, Id(nh, nw), p, pi));
                        }
                    }
                }
            }
            for(int k = 0; k < 3; k++)
            {
                if(chmin(ref dist[now][cl][k],cst+1+W))
                {
                    pq.Push((cst + 1+W, now, cl, k));
                }
            }
        }
        var res = dist[R[N * N - 1]][N * N - 1].Min();
        Console.WriteLine($"{res / W} {res % W}");
    }
    int N;
    const long W = (long)1e9;
    public int Id(int h, int w) => h * N + w;
    int[] knH = new[] { -2, -2, -1, -1, 1, 1, 2, 2 }, knW = new[] { 1, -1, 2, -2, 2, -2, 1, -1 };
    public static bool Inside(int h, int w, int H, int W)
        => 0 <= h && h < H && 0 <= w && w < W;
}

public class PriorityQueue<T>
{
    private List<T> data = new List<T>();
    private Comparison<T> cmp;
    public int Count { get { return data.Count; } }
    public T Top { get { return data[0]; } }
    public PriorityQueue() { cmp = cmp ?? Comparer<T>.Default.Compare; }

    public PriorityQueue(Comparison<T> comparison) { cmp = comparison; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private int Parent(int i)
        => (i - 1) >> 1;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private int Left(int i)
        => (i << 1) + 1;
    public T Push(T val)
    {
        int i = data.Count;
        data.Add(val);
        while (i > 0)
        {
            int p = Parent(i);
            if (cmp(data[p], val) <= 0)
                break;
            data[i] = data[p];
            i = p;
        }
        data[i] = val;
        return val;
    }
    public T Pop()
    {
        var ret = data[0];
        var p = 0;
        var x = data[data.Count - 1];
        while (Left(p) < data.Count - 1)
        {
            var l = Left(p);
            if (l < data.Count - 2 && cmp(data[l + 1], data[l]) < 0) l++;
            if (cmp(data[l], x) >= 0)
                break;
            data[p] = data[l];
            p = l;
        }
        data[p] = x;
        data.RemoveAt(data.Count - 1);
        return ret;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public bool Any() => data.Count > 0;
}
#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var sol = new Solver() { sc = new Scanner() };
        //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
        sol.Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static void Out<T>(this IList<T> A, out T a) => a = A[0];
    public static void Out<T>(this IList<T> A, out T a, out T b) { a = A[0]; b = A[1]; }
    public static void Out<T>(this IList<T> A, out T a, out T b, out T c) { A.Out(out a, out b); c = A[2]; }
    public static void Out<T>(this IList<T> A, out T a, out T b, out T c, out T d) { A.Out(out a, out b, out c); d = A[3]; }
    public static string Concat<T>(this IEnumerable<T> A, string sp) => string.Join(sp, A);
    public static char ToChar(this int s, char begin = '0') => (char)(s + begin);
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int ArgMax<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next<T7>(); }
    public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}

#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforces
{
  public class Program
  {
    static void Main(string[] args)
    {
      string s = Console.ReadLine();
      int R = s.IndexOf('R') %4;
      int B = s.IndexOf('B') %4;
      int Y = s.IndexOf('Y') %4;
      int G = s.IndexOf('G') %4;

      List<int> l = new List<int> { 0,0,0,0};
      for (int i = 0; i < s.Length; i++)
      {
        if (s[i] == '!')
          l[i%4]++;
      }
      Console.WriteLine(l[R]+" "+l[B]+" "+l[Y]+" "+l[G]);
    }
  }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace Temp
{
    struct PointInt
    {
        public long X;

        public long Y;

        public PointInt(long x, long y)
            : this()
        {
            this.X = x;
            this.Y = y;
        }

        public static PointInt operator +(PointInt a, PointInt b)
        {
            return new PointInt(a.X + b.X, a.Y + b.Y);
        }

        public static PointInt operator -(PointInt a, PointInt b)
        {
            return new PointInt(a.X - b.X, a.Y - b.Y);
        }

        public static PointInt operator *(PointInt a, long k)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public static PointInt operator *(long k, PointInt a)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public bool IsInsideRectangle(long l, long b, long r, long t)
        {
            return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);
        }
    }

    struct LineInt
    {
        public LineInt(PointInt a, PointInt b)
            : this()
        {
            A = a.Y - b.Y;
            B = b.X - a.X;
            C = a.X * b.Y - a.Y * b.X;
        }

        public long A, B, C;

        public bool Contains(PointInt p)
        {
            return A * p.X + B * p.Y + C == 0;
        }
    }

    class MatrixInt
    {
        private long[,] m_Matrix;

        public int Size
        {
            get
            {
                return m_Matrix.GetLength(0) - 1;
            }
        }

        public long Mod { get; private set; }

        public MatrixInt(int size, long mod = 0)
        {
            m_Matrix = new long[size + 1, size + 1];
            Mod = mod;
        }

        public MatrixInt(long[,] matrix, long mod = 0)
        {
            this.m_Matrix = matrix;
            Mod = mod;
        }

        public static MatrixInt GetIdentityMatrix(int size, long mod = 0)
        {
            long[,] matrix = new long[size + 1, size + 1];

            for (int i = 1; i <= size; i++)
            {
                matrix[i, i] = 1;
            }

            return new MatrixInt(matrix, mod);
        }

        public long this[int i, int j]
        {
            get
            {
                return m_Matrix[i, j];
            }

            set
            {
                m_Matrix[i, j] = value;
            }
        }

        public static MatrixInt operator +(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);
            long[,] c = new long[n, n];
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    c[i, j] = a[i, j] + b[i, j];
                }
            }

            if (mod > 0)
            {
                for (int i = 1; i <= n; i++)
                {
                    for (int j = 1; j <= n; j++)
                    {
                        c[i, j] %= mod;
                    }
                }
            }

            return new MatrixInt(c, mod);
        }

        public static MatrixInt operator *(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);

            long[,] c = new long[n, n];

            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    for (int k = 1; k <= n; k++)
                    {
                        c[i, j] += a[i, k] * b[k, j];
                        if (mod > 0)
                        {
                            c[i, j] %= mod;
                        }
                    }
                }
            }

            return new MatrixInt(c, mod);
        }
    }

    static class Algebra
    {
        public static long Phi(long n)
        {
            long result = n;
            for (long i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    while (n % i == 0)
                    {
                        n /= i;
                    }

                    result -= result / i;
                }
            }

            if (n > 1)
            {
                result -= result / n;
            }

            return result;
        }

        public static long BinPower(long a, long n, long mod)
        {
            long result = 1;

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result = (result * a) % mod;
                }

                a = (a * a) % mod;
                n >>= 1;
            }

            return result;
        }

        public static class Permutations
        {
            public static int[] GetRandomPermutation(int n)
            {
                int[] p = new int[n];
                for (int i = 0; i < n; i++)
                {
                    p[i] = i;
                }

                Random random = new Random();
                for (int i = n - 1; i > 0; i--)
                {
                    int j = random.Next(i + 1);
                    int tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                }

                return p;
            }
        }

        public static T[] Shuffle<T>(this T[] array)
        {
            int length = array.Length;
            int[] p = Permutations.GetRandomPermutation(length);
            T[] result = new T[length];
            for (int i = 0; i < length; i++)
            {
                result[i] = array[p[i]];
            }

            return result;
        }

        public static MatrixInt MatrixBinPower(MatrixInt a, long n)
        {
            MatrixInt result = new MatrixInt(a.Size);

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result *= a;
                }

                a *= a;
                n >>= 1;
            }

            return result;
        }

        public static long Gcd(long a, long b)
        {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static long ExtendedGcd(long a, long b, out long x, out long y)
        {
            if (b == 0)
            {
                x = 1;
                y = 0;
                return a;
            }

            long x1;
            long y1;
            long d = ExtendedGcd(b, a % b, out x1, out y1);
            x = y1;
            y = x1 - (a / b) * y1;
            return d;
        }

        public static long Lcm(long a, long b)
        {
            return (a / Gcd(a, b)) * b;
        }

        public static bool[] GetPrimes(int n)
        {
            n = Math.Max(n, 2);
            bool[] prime = new bool[n + 1];
            for (int i = 2; i <= n; i++)
            {
                prime[i] = true;
            }

            for (int i = 2; i * i <= n; i++)
            {
                if (prime[i])
                {
                    if ((long)i * i <= n)
                    {
                        for (int j = i * i; j <= n; j += i)
                        {
                            prime[j] = false;
                        }
                    }
                }
            }

            return prime;
        }

        public static long GetFibonacciNumber(long n, long mod = 0)
        {
            long[,] matrix = new long[,] { { 0, 0, 0 }, { 0, 0, 1 }, { 0, 1, 1 } };

            MatrixInt result = MatrixBinPower(new MatrixInt(matrix, mod), n);

            return result[2, 2];
        }

        public static long[] GetFibonacciSequence(int n)
        {
            long[] result = new long[n];
            result[0] = result[1] = 1;

            for (int i = 2; i < n; i++)
            {
                result[i] = result[i - 1] + result[i - 2];
            }

            return result;
        }

        public static long GetInverseElement(long a, long mod)
        {
            long x, y;
            long g = ExtendedGcd(a, mod, out x, out y);

            if (g != 1)
            {
                return -1;
            }

            return ((x % mod) + mod) % mod;
        }

        public static long[] GetAllInverseElements(long mod)
        {
            long[] result = new long[mod];
            result[1] = 1;
            for (int i = 2; i < mod; i++)
            {
                result[i] = (mod - (((mod / i) * result[mod % i]) % mod)) % mod;
            }

            return result;
        }
    }

    internal static class Reader
    {
        public static void ReadInt(out int a)
        {
            int[] number = new int[1];
            ReadInt(number);
            a = number[0];
        }

        public static void ReadInt(out int a, out int b)
        {
            int[] numbers = new int[2];
            ReadInt(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadInt(out int int1, out int int2, out int int3)
        {
            int[] numbers = new int[3];
            ReadInt(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static void ReadInt(out int int1, out int int2, out int int3, out int int4)
        {
            int[] numbers = new int[4];
            ReadInt(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
            int4 = numbers[3];
        }

        public static void ReadLong(out long a)
        {
            long[] number = new long[1];
            ReadLong(number);
            a = number[0];
        }

        public static void ReadLong(out long a, out long b)
        {
            long[] numbers = new long[2];
            ReadLong(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadLong(out long int1, out long int2, out long int3)
        {
            long[] numbers = new long[3];
            ReadLong(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static void ReadLong(out long int1, out long int2, out long int3, out long int4)
        {
            long[] numbers = new long[4];
            ReadLong(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
            int4 = numbers[3];
        }

        public static void ReadInt(int[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = int.Parse(list[i]);
            }
        }

        public static int[] ReadDigits()
        {
            // ReSharper disable AssignNullToNotNullAttribute
            return Console.ReadLine().Select(x => int.Parse(x.ToString())).ToArray();
            // ReSharper restore AssignNullToNotNullAttribute
        }

        public static void ReadLong(long[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = long.Parse(list[i]);
            }
        }

        public static void ReadDouble(double[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = double.Parse(list[i]);
            }
        }

        public static void ReadDouble(out double a, out double b)
        {
            double[] numbers = new double[2];
            ReadDouble(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadDouble(out double int1, out double int2, out double int3)
        {
            double[] numbers = new double[3];
            ReadDouble(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }
    }

    static class MyMath
    {
        public static int GetMinimalPrimeDivisor(int n)
        {
            for (int i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    return i;
                }
            }

            return n;
        }

        public static long Sqr(long x)
        {
            return x * x;
        }
    }

    public interface IGraph
    {
        int Vertices  { get; set; }

        IList<int> this[int i] { get; }

        void AddEdge(int u, int v);

        void AddOrientedEdge(int u, int v);
    }

    public class Graph : IGraph
    {
        private List<int>[] m_Edges;

        public int Vertices { get; set; }

        public IList<int> this[int i]
        {
            get
            {
                return this.m_Edges[i];
            }
        }

        public Graph(int vertices)
        {
            this.Vertices = vertices;

            this.m_Edges = new List<int>[vertices];

            for (int i = 0; i < vertices; i++)
            {
                this.m_Edges[i] = new List<int>();
            }
        }

        public void AddEdge(int u, int v)
        {
            this.AddOrientedEdge(u, v);
            this.AddOrientedEdge(v, u);
        }

        public void AddOrientedEdge(int first, int second)
        {
            this.m_Edges[first].Add(second);
        }

        public int[] Bfs(int start)
        {
            int[] d = new int[Vertices];
            for (int i = 0; i < Vertices; i++)
            {
                d[i] = -1;
            }

            Queue<int> queue = new Queue<int>();
            queue.Enqueue(start);
            d[start] = 0;

            while (queue.Count > 0)
            {
                int v = queue.Dequeue();
                foreach (int t in this.m_Edges[v].Where(t => d[t] == -1))
                {
                    queue.Enqueue(t);
                    d[t] = d[v] + 1;
                }
            }

            return d;
        }
    }

    class SimpleSumTable
    {
        private readonly int[,] m_Sum;

        public SimpleSumTable(int n, int m, int[,] table)
        {
            m_Sum = new int[n + 1, m + 1];

            for (int i = 1; i < n + 1; i++)
            {
                for (int j = 1; j < m + 1; j++)
                {
                    m_Sum[i, j] = m_Sum[i, j - 1] + m_Sum[i - 1, j] - m_Sum[i - 1, j - 1] + table[i, j];
                }
            }
        }

        public int GetSum(int l, int b, int r, int t)
        {
            return m_Sum[r, t] - m_Sum[r, b] - m_Sum[l, t] + m_Sum[l, b];
        }
    }

    class SegmentTreeSimpleInt<T>
    {
        public int Size { get; private set; }

        private readonly T[] m_Tree;

        private Func<T, T, T> m_Operation;

        private T m_Null;

        public SegmentTreeSimpleInt(int size, Func<T, T, T> operation, T nullElement, IList<T> array = null)
        {
            this.Size = size;
            this.m_Operation = operation;
            this.m_Null = nullElement;

            m_Tree = new T[4 * size];
            if (array != null)
            {
                this.Build(array, 1, 0, size - 1);
            }
        }

        private void Build(IList<T> array, int v, int tl, int tr)
        {
            if (tl == tr)
            {
                m_Tree[v] = array[tl];
            }
            else
            {
                int tm = (tl + tr) / 2;
                this.Build(array, 2 * v, tl, tm);
                this.Build(array, 2 * v + 1, tm + 1, tr);
                this.CalculateNode(v);
            }
        }

        public T GetSum(int l, int r)
        {
            return GetSum(1, 0, Size - 1, l, r);
        }

        private T GetSum(int v, int tl, int tr, int l, int r)
        {
            if (l > r)
            {
                return m_Null;
            }

            if (l == tl && r == tr)
            {
                return m_Tree[v];
            }

            int tm = (tl + tr) / 2;

            return this.m_Operation(GetSum(2 * v, tl, tm, l, Math.Min(r, tm)),GetSum(2 * v + 1, tm + 1, tr, Math.Max(l, tm + 1), r));
        }

        public void Update(int pos, T newValue)
        {
            Update(1, 0, Size - 1, pos, newValue);
        }

        private void Update(int v, int tl, int tr, int pos, T newValue)
        {
            if (tl == tr)
            {
                m_Tree[v] = newValue;
            }
            else
            {
                int tm = (tl + tr) / 2;
                if (pos <= tm)
                {
                    Update(2 * v, tl, tm, pos, newValue);
                }
                else
                {
                    Update(2 * v + 1, tm + 1, tr, pos, newValue);
                }
                this.CalculateNode(v);
            }
        }

        private void CalculateNode(int v)
        {
            m_Tree[v] = this.m_Operation(m_Tree[2 * v], m_Tree[2 * v + 1]);
        }
    }

    struct Pair<TFirst, TSecond>
    {
        public Pair(TFirst first, TSecond second)
            : this()
        {
            this.First = first;
            this.Second = second;
        }

        public TFirst First { set; get; }

        public TSecond Second { set; get; }
    }

    class Program
    {
        private static StreamReader m_InputStream;

        private static StreamWriter m_OutStream;

        private static void OpenFiles()
        {
            m_InputStream = File.OpenText("input.txt");
            Console.SetIn(m_InputStream);

            m_OutStream = File.CreateText("output.txt");
            Console.SetOut(m_OutStream);
        }

        private static void CloseFiles()
        {
            m_OutStream.Flush();

            m_InputStream.Dispose();
            m_OutStream.Dispose();
        }

        static void Main()
        {
            //OpenFiles();

            new Solution().Solve();

            //CloseFiles();
        }
    }

    internal class Solution
    {
        public void Solve()
        {
            double a, b, m, x, y, z;
            Reader.ReadDouble(out a, out b, out m);
            Reader.ReadDouble(out x, out y, out z);

            double time = m / y;

            x = a / 2 - x * time;
            while (!(0 <= x && x <= a))
            {
                if (x < 0)
                {
                    x = -x;
                }
                if (x > a)
                {
                    x = 2 * a - x;
                }
            }

            z = z * time;
            while (!(0 <= z && z <= b))
            {
                if (z < 0)
                {
                    z = -z;
                }
                if (z > b)
                {
                    z = 2 * b - z;
                }
            }

            Console.Write(x.ToString(CultureInfo.InvariantCulture));
            Console.Write(" ");
            Console.Write(z.ToString(CultureInfo.InvariantCulture));
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Kyoya_and_Permutation
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            var fib = new List<long> {1, 1};
            do
            {
                fib.Add(fib[fib.Count - 1] + fib[fib.Count - 2]);
            } while (fib[fib.Count - 1] > 0);

            long n = Next();
            long m = Next()-1;

            var bb = new List<bool>();
            for (int i = fib.Count - 2; i > 0; i--)
            {
                if (m >= fib[i])
                {
                    bb.Add(true);
                    m -= fib[i];
                }
                else
                {
                    bb.Add(false);
                }
            }

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = i + 1;
            }

            int index = bb.Count - 1;
            for (long i = n - 2; i >= 0; i--)
            {
                if (bb[index])
                {
                    int c = nn[i];
                    nn[i] = nn[i + 1];
                    nn[i + 1] = c;
                }

                index--;
            }

            foreach (int i in nn)
            {
                writer.Write(i);
                writer.Write(' ');
            }
            writer.Flush();
        }

        private static long Next()
        {
            int c;
            long res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    public class Program
    {
        public static void Main()
        {
            int[] parameters;
            char[,] array;
            string temp;
            int PigsEaten = 0;

            parameters = Console.ReadLine().Split(' ').Select(n => Convert.ToInt32(n)).ToArray();

            array = new char[parameters[0], parameters[1]];

            for(int i = 0; i < parameters[0]; ++i)
            {
                temp = Console.ReadLine();
                for (int j = 0; j < parameters[1]; ++j)
                {
                    array[i, j] = temp[j];
                }
            }

            for(int i = 0; i < parameters[0]; ++i)
                for (int j = 0; j < parameters[1]; ++j)
                {
                    if (array[i, j] == 'W')
                    {
                        if (i + 1 < parameters[0] && array[i + 1, j] == 'P')
                            ++PigsEaten;
                        else if (j + 1 < parameters[1] && array[i, j + 1] == 'P')
                            ++PigsEaten;
                        else if (i -1 >= 0 && array[i - 1, j] == 'P')
                            ++PigsEaten;
                        else if (j - 1 >= 0 && array[i, j - 1] == 'P')
                            ++PigsEaten;
                    }
                }

            Console.WriteLine(PigsEaten);
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

namespace mainnm
{
    class main
    {
        /**
         * Работает с массивом без повторяющихся элементов
        **/
        static int binarySearch(int[] array, int element) {
            int start = 0;
            int end = array.Length;
            int position = (start - end) / 2;

            while (start - end != 0) {
                if (array[position] == element) return position;

            }

            return 0;
        }

        static void Main()
        {
            int a = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).Sum();
            int b = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).Sum();
            int n = int.Parse(Console.ReadLine());

            int shelf = 0;
            shelf += a / 5;
            if (a % 5 != 0) shelf++;

            shelf += b / 10;
            if (b % 10 != 0) shelf++;

            Console.WriteLine(shelf > n ? "NO" : "YES");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForce
{
    class Program
    {
        static int GetDif(int target, int num)
        {
            if (target == num)
                return 0;
            if (target < num)
                return num - target;

            int t = (int)Math.Ceiling( Math.Log((double)target / num) / Math.Log(2) );
            int d = (int)(num * Math.Pow(2, t)-target);
            int n1 = d;
            n1 = (n1 >> (t+1)) << (t + 1);

            int n2 = d;
            n2 = n2 - n1;

            int count = n1 /(int) Math.Pow(2, t);
            count += t;

            while (n2>0)
            {
                n2 &= n2 - 1;
                count++;
            }
            return count;
        }

        static void Main(string[] args)
        {

            var line = Console.ReadLine();
            var input = line.Split(' ');
            int a = Int32.Parse(input[0]);
            int target = Int32.Parse(input[1]);
            var res = GetDif(target, a);
            Console.WriteLine(res);
        }
    }
}


using System;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Globalization;
using System.Collections.Generic;
using System.Threading;

namespace CodeForces
{
	internal class B
	{
		class Lem : IComparable<Lem>
		{
			public int Mass { get; set; }
			public int Speed { get; set; }
			public int Id { get; set; }
			public int CompareTo( Lem other )
			{
				if ( Mass != other.Mass )
					return Mass.CompareTo( other.Mass );
				else return Speed.CompareTo( other.Speed );
			}
		}
		private void Solve()
		{
			int n = NextInt(), k = NextInt(), h = NextInt();
			Lem[] a = new Lem[n];
			for ( int i = 0; i < n; ++i )
			{
				a[i] = new Lem();
				a[i].Mass = NextInt();
				a[i].Id = i + 1;
			}
			for ( int i = 0; i < n; ++i )
			{
				a[i].Speed = NextInt();
			}
			Random rnd = new Random( 123 );
			for ( int i = 1; i < n; ++i )
			{
				int j = rnd.Next( i + 1 );
				Lem tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
			Array.Sort( a );

			double l = 0, r = 1000000009;
			for ( int times = 0; times < 200; ++times )
			{
				double m = ( l + r ) / 2;
				if ( can( a, m, k, h ) ) r = m; else l = m;
			}
			var res = get( a, r, k, h );
			foreach ( var re in res )
			{
				Out.Write( re + " " );
			}
		}

		private bool can( Lem[] lems, double m, int k, int h )
		{
			int need = k;
			for ( int i = lems.Length - 1; i >= 0; --i )
			{
				double mx = Math.Min( k, m * lems[i].Speed / h );
				if ( mx >= need )
				{
					--need;
				}
				if ( need == 0 ) break;
			}
			return need == 0;
		}

		private List<int> get( Lem[] lems, double m, int k, int h )
		{
			List<int> res = new List<int>();
			int need = k;
			for ( int i = lems.Length - 1; i >= 0; --i )
			{
				double mx = Math.Min( k, m * lems[i].Speed / h );
				if ( mx >= need )
				{
					--need;
					res.Add( lems[i].Id );
				}
				if ( need == 0 ) break;
			}
			res.Reverse();
			return res;
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, 20000000 );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new B().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}


using System;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Globalization;
using System.Collections.Generic;
using System.Threading;

namespace CodeForces
{

	class A
	{

		private void Solve()
		{
			int n = NextInt(), m = NextInt(), k = NextInt();
			int[,] a = new int[n, m], b = new int[n, m], c = new int[n, m];
			long res = 0;
			for ( int i = 0; i < n; ++i )
			{
				var name = NextLine();
				for ( int j = 0; j < m; ++j )
				{
					a[i, j] = NextInt();
					b[i, j] = NextInt();
					c[i, j] = NextInt();
				}
			}

			int[] cc = new int[m];

			for ( int i = 0; i < n; ++i )
				for ( int j = 0; j < n; ++j )
					if ( i != j )
					{
						for ( int t = 0; t < m; ++t ) cc[t] = c[i, t];
						int can = k;
						long cur = 0;
						while ( can > 0 )
						{
							int maxV = 0, tt = -1;
							for ( int t = 0; t < m; ++t )
								if ( cc[t] > 0 && b[j, t] - a[i, t] > maxV )
								{
									maxV = b[j, t] - a[i, t];
									tt = t;
								}
							if ( tt == -1 ) break;
							int sell = Math.Min( c[i, tt], can );
							cur += (long)sell * maxV;
							can -= sell;
							cc[tt] -= sell;
						}
						res = Math.Max( res, cur );
					}
			Out.WriteLine( res );
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, 20000000 );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new A().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}


using System;
using System.IO;
using System.Text;

namespace Golden_Plate
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            int w = Next(), h = Next(), k = Next();

            int ans = 0;
            for (int i = 0; i < k; i++)
            {
                ans += 2*w + 2*h - 4;
                w -= 4;
                h -= 4;
            }
            return ans;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[]str = Console.ReadLine().Split();
		long U = long.Parse(str[0]);
		long V = long.Parse(str[1]);
		if(U==0){
			if(V==0){
				Console.WriteLine("0");
			} else if(V%2==0){
				Console.WriteLine("2");
				Console.WriteLine(V/2+" "+V/2);
			} else {
				Console.WriteLine("-1");
			}
		} else if(U>V){
			Console.WriteLine("-1");
		} else {
			V -= U;
			if(V==0){
				Console.WriteLine("1");
				Console.WriteLine(U);
			} else if(V%2==0){
				long x = 1;
				bool flag = true;
				while(x<V){
					if(U/x%2==1 && V/2/x%2==1){
						flag = false;
						break;
					}
					x *= 2;
				}
				if(flag){
					Console.WriteLine("2");
					Console.WriteLine((U+V/2)+" "+V/2);
				} else {
					Console.WriteLine("3");
					Console.WriteLine(U+" "+V/2+" "+V/2);
				}
			} else {
				Console.WriteLine("-1");
			}
		}
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Test
    {
        public static void Main()
        {
            //Initializing variables and input
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();
            string s3 = Console.ReadLine();
            string s4 = Console.ReadLine();

            string[] sh1 = s1.Split(null);
            string[] sh2 = s2.Split(null);
            string[] sh3 = s3.Split(null);
            string[] sh4 = s4.Split(null);

            Int64[] n1 = new Int64[2];
            Int64[] n2 = new Int64[2];

            for(int i=0; i < 2; i++)
            {
                n1[i] = Int64.Parse(sh1[i]);
            }

            for (int i = 0; i < 2; i++)
            {
                n2[i] = Int64.Parse(sh3[i]);
            }

            Int64[] d1 = new Int64[n1[0]];
            Int64[] d2 = new Int64[n2[0]];

            for (int i = 0; i < n1[0]; i++)
            {
                d1[i] = Int64.Parse(sh2[i]);
            }

            for (int i = 0; i < n2[0]; i++)
            {
                d2[i] = Int64.Parse(sh4[i]);
            }

            //Execution

            Int64 num1 = 0;
            Int64 num2 = 0;

            for(int i = 0 ; i < n1[0] ; i++)
            {
                num1 = num1 + ((d1[n1[0] - i - 1]) * Convert.ToInt64(Math.Pow(n1[1], i)));
            }

            for (int i = 0; i < n2[0]; i++)
            {
                num2 = num2 + ((d2[n2[0] - i - 1]) * Convert.ToInt64(Math.Pow(n2[1], i)));
            }

            if(num1 == num2)
            {
                Console.WriteLine("=");
            }
            else if (num1 > num2)
            {
                Console.WriteLine(">");
            }
            else
            {
                Console.WriteLine("<");
            }
        }
    }
}


using System;

namespace Codeforces
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			new Solution();
		}
	}
	class Solution
	{
		public Solution(){
            int x = int.Parse(Console.ReadLine());
            if (x == 1)
            {
                Console.WriteLine("1");
                return;
            }
            String sx = x.ToString();
            int count = 1;
            for (int i = 1; i <= Math.Sqrt(x); i++)
            {
                char[] si = i.ToString().ToCharArray();
                if (x % i == 0 && sx.IndexOfAny(si) >= 0)
                {
                    count++;
                }
                if (i > 1 && i != x / i && x % (x / i) == 0)
                {
                    char[] ssi = (x / i).ToString().ToCharArray();
                    if(sx.IndexOfAny(ssi)>=0)
                        count++;
                }
            }
            Console.Write(count);
            //Console.ReadKey(true);

		}
	}
}
/*A
int n=int.Parse(Console.ReadLine());
Console.Write(n+" ");
for (int i = 1; i < n; i++)
{
    Console.Write(i + " ");
}
*/

/* B
            int x = int.Parse(Console.ReadLine());
            if (x == 1)
            {
                Console.WriteLine("1");
                return;
            }
            String sx=x.ToString();
            int count=1;
            for (int i = 1; i <= Math.Sqrt(x); i++)
            {
                char[] si=i.ToString().ToCharArray();
                if (x%i==0 && sx.IndexOfAny(si)>=0)
                {
                        count++;
                 }
            }
            Console.Write(count);
            */
/*C
            int n = int.Parse(Console.ReadLine());
            String s=Console.ReadLine();
            String[] z=s.Split(' ');
            int[] c = new int[n];
            for (int i = 0; i < n; i++)
            {
                c[i] = int.Parse(z[i]);
            }
            int count = 0;
            for (int i = 1; i < n; i++)
            {
                if (c[i - 1] > c[i]) count++;
                if (count > 2)
                {
                    Console.WriteLine("NO");
                    return;
                }
            }
            if (count == 2 || count ==0)
            {
                Console.WriteLine("YES");
                return;
            }
            if (count == 1)
            {
                int i=0;
                while (c[i] <= c[i + 1]) i++;
                int p=c[i];
                int t=c[i+1];i++;
                while (i<n && c[i] == t) i++;
                if (i == n)
                {
                    Console.WriteLine("YES");
                    return;
                }
                if (c[i] == p)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
            */


using System; using System.Linq; using System.Collections.Generic;

class P {
  static void Main() {
    var s = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    var res = GetPrices(s[0], s[1]).Last();
    Console.Write(res);
  }

  static IEnumerable<long> GetPrices(long p, long d) {
    yield return p;
    var min = p - d;
    var mult = 10L;
    while (true) {
      p -= (1 + p%mult) % mult;
      if (p < min) yield break;
      yield return p;
      mult *= 10;
    }
  }
}


using System;
using System.IO;
using System.Text;

namespace Turn
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            long n = long.Parse(reader.ReadLine());

            n %= 360;

            if (n >= 0)
            {
                if (n <= 45)
                    writer.WriteLine("0");
                else if (n <= 45 + 90)
                    writer.WriteLine("1");
                else if (n <= 45 + 180)
                    writer.WriteLine("2");
                else if (n < 45 + 270)
                    writer.WriteLine("3");
                else
                {
                    writer.WriteLine("0");
                }
            }
            else
            {
                if (n >= -45)
                    writer.WriteLine("0");
                else if (n > -45 - 90)
                    writer.WriteLine("3");
                else if (n > -45 - 180)
                    writer.WriteLine("2");
                else if (n > -45 - 270)
                    writer.WriteLine("1");
                else
                {
                    writer.WriteLine("0");
                }
            }

            writer.WriteLine();
            writer.Flush();
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace cdfRound
{
    class MainClass
    {
        public static void Main()
        {
            string input = Console.ReadLine();
            int[] first = new int[3];
            int[] second = new int[3];
            int sum1 = 0, sum2 = 0;
            for (int i = 0; i < 3; i++)
            {
                first[i] = int.Parse(input[i].ToString());
                sum1 += first[i];
            }
            for (int i = 3; i < 6; i++)
            {
                second[i - 3] = int.Parse(input[i].ToString());
                sum2 += second[i - 3];
            }
            if (sum1 == sum2)
                Console.WriteLine(0);
            else
            {
                if (sum1 > sum2)
                {
                    int[] el = new int[6];
                    for (int i = 0; i < 3; i++)
                        el[i] = 9 - second[i];
                    for (int i = 0; i < 3; i++)
                        el[i + 3] = first[i];
                    int sum = sum1 - sum2;
                    Array.Sort(el);
                    if (sum <= el[5]) Console.WriteLine(1);
                    else if (sum <= (el[5] + el[4])) Console.WriteLine(2);
                    else Console.WriteLine(3);
                }
                else
                {
					int[] el = new int[6];
					for (int i = 0; i < 3; i++)
                        el[i] = 9 - first[i];
					for (int i = 0; i < 3; i++)
                        el[i + 3] = second[i];
					int sum = sum2 - sum1;
					Array.Sort(el);
					if (sum <= el[5]) Console.WriteLine(1);
					else if (sum <= (el[5] + el[4])) Console.WriteLine(2);
					else Console.WriteLine(3);
                }
            }
        }
    }
}


using System;
using System.Linq;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ');
            var n = Int32.Parse(arr[0]);
            var m = long.Parse(arr[1]);
            var res = GetRes(n, m);
            Console.WriteLine(res);

            // Test();
        }

        const int MOD_VAL = 998244353;
        private static int GetRes(int n, long m)
        {
            if (n == 1) return 0;
            var fullCount = GetFullCount(n, m);
            var noOk = GetNOKCount(n,m);
            var res = fullCount - noOk;
            if(res < 0) res+=MOD_VAL;
            return res;
        }

        private static int GetFullCount(int n, long m)
        {
            var divisor = (int)((m-1) % MOD_VAL);
            if (divisor == 0) return n;
            var reverse = GetReverse(divisor);
            var mAfterMod = (int)(m % MOD_VAL);
            var res = (int)(((long)GetPow(mAfterMod, n+1) - mAfterMod) *
                reverse % MOD_VAL);
            if (res < 0) res+=MOD_VAL;
            return res;
        }

        private static int GetReverse(int val)
        {
            var (a,b) = ExGcd(MOD_VAL, val);
            return b >= 0 ? (int) b: (int)(MOD_VAL+b);
        }

        private static (long, long) ExGcd(long num0, long num1)
        {
            if (num0 % num1 == 0)
            {
                return (0, 1);
            }
            // a0 * num0 + b0 * num1 = num2
            var num2 = num0 % num1;
            var a0 = 1;
            var b0 = -(num0 / num1);
            // a1 * num1 + b1 * num2 = gcd
            var (a1, b1) = ExGcd(num1, num2);
            // (a0*b1) * num0 + (a1 + b0*b1) * num1 = gcd
            return (a0 * b1, a1 + b0 * b1);
        }

        private static int GetPow(int baseVal, int exponent)
        {
            var index = 0;
            var res = 1L;
            long tmp = baseVal;
            while(1<<index <= exponent)
            {
                if ((1<<index & exponent)!=0)
                {
                    res = res * tmp % MOD_VAL;
                }
                tmp = tmp * tmp % MOD_VAL;
                index++;
            }
            return (int)res;
        }

        private static int GetNOKCount(int n, long m)
        {
            var primes = new int[]
            {
                2,3,5,7,11,13,17,19,23,29,31,37
            };
            var product = 1L;
            var noOkI = m % MOD_VAL;
            var noOk = noOkI;
            for(var i =2;i<=n;i++)
            {
                if(primes.Contains(i))
                {
                    product*=i;
                }
                if( m < product)
                {
                    break;
                }
                noOkI = noOkI * (m/product % MOD_VAL) % MOD_VAL;
                noOk = (noOk + noOkI) % MOD_VAL;
            }
            return (int)noOk;
        }

        private static (int,int) GetTestData(Random random)
        {
            return (random.Next(10)+3, random.Next(4));
        }

    }
}


using System;

namespace _779B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string n = input[0]; int k = int.Parse(input[1]);
            int i = input[0].Length - 1, s = 0;
            while (i > 0 && k > 0)
            {
                if (n[i] == '0') k--;
                else s++;
                i--;
            }
            if (k == 0) Console.WriteLine(s);
            else Console.WriteLine(n.Length - 1);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace олимпиадное_программирование
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            if(x==1)
                Console.WriteLine(-1);
            else
            {
                if(x%2==0)
                    Console.WriteLine("{0} {1}", x,2);
                else
                    Console.WriteLine("{0} {1}", x-1, 2);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeForces
{
    class R172_Div2_B
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int x = int.Parse(s[0]);
            int y = int.Parse(s[1]);
            int n = int.Parse(s[2]);
            double dx = (double) x;
            double dy = (double) y;

            long mina = 0, minb = 0;
            double min = long.MaxValue;
            for (long b = 1; b <= n; b++)
            {
                double db = (double)b;
                long aMin = b * x / y;
                long aMax = Convert.ToInt64(Math.Ceiling(db * dx / dy));

                for (long a = aMin; a <= aMax; a++)
                {
                    double da = (double)a;
                    double d = Math.Abs(dx / dy - da / db);
                    d = Math.Floor(d * 1e15) / 1e15;
                    if (d < min)
                    {
                        min = d;
                        mina = a;
                        minb = b;
                    }
                }
            }

            Console.WriteLine(mina + "/" + minb);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CyberMainProject
{
    class CyberMainClass
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int min = 0, max = 0;
            if (n <= 2)
            {
                min = 0;
                max = n;
            }
            else if (n <= 5)
            {
                min = 0;
                max = 2;
            }
            else if (n>5)
            {
                if (n >= 7 && n%7 == 0)
                {
                    min = (n/7)*2;
                    max = (n/7)*2;
                }
                else
                {
                    if (n == 6)
                    {
                        min = 1;
                        max = 2;
                    }
                    else
                    {
                        int m = n/7;
                        min = m *2;
                        max = m *2;
                        int t = n-(m*7);
                        if (t <= 2)
                        {
                            max += t;
                        }
                        else
                        {

                            max += 2;
                            if (t == 6)
                            {
                                min +=1;
                            }
                        }
                    }
                }
            }
            Console.WriteLine(min + " " +max);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CF_273_d {
  public class Program {

    public static int r;
    public static int g;
    public static int h;
    public static int cntRG;
    public static ulong[] a;
    public static ulong[] ap;
    public static int n;
    public static int c1;
    public static int c2;
    public static ulong max = 1000000007;
    //public static ulong max = 1000000000;
    public static ulong maxCnt = 0;

    public static void Main(string[] args) {

      string[] str = Console.ReadLine().Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
      r = int.Parse(str[0]);
      g = int.Parse(str[1]);

      ulong cnt = Func1();

      Console.WriteLine(cnt);
      Console.ReadLine();
    }

    public static ulong Func1() {

      double d = 1 + 4 * (r + g) * 2;
      double x = (-1 + Math.Sqrt(d)) / 2;
      h = (int)x;
      cntRG = (h + 1) * h / 2;
      c1 = r;
      c2 = g;
      if(g < c1) {
        c1 = g;
        c2 = r;
      }

      if(c1 == 0) return 1;

      a = new ulong[c1 + 1];
      ap = new ulong[c1 + 1];

      a[0] = 1;
      a[1] = 1;

      n = 1;
      Func2();

      ulong sumA = 0;
      for(int i = 0; i <= c1; i++) {
        sumA += a[i];
        if(sumA > max) {
          maxCnt+= sumA / max;
          sumA = sumA % max;
        }
      }

      return sumA;

    }

    public static void Func2() {

      while(n < h) {
        Array.Copy(a, ap, a.Length);
        n++;
        for(int i = 0; i <= c1; i++) {
          int k1 = i - n;
          ulong a1 = 0;
          if(k1 >= 0) a1 = ap[k1];

          int cnt = (n + 1) * n / 2;
          int gi = cnt - i;
          ulong a2 = 0;
          if(gi <= c2) {
            a2 = ap[i];
          }

          a[i] = a1 + a2;

          if(a[i] > max) {
            a[i] %= max;
          }
        }
      }
    }
  }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces_CS
{
    class Class1
    {
        static void Main(string[] args)
        {
            new Class1().run();
        }

        int bpb = 0;
        int spb = 0;
        int cpb = 0;
        int bh = 0;
        int sh = 0;
        int ch = 0;
        int bp = 0;
        int sp = 0;
        int cp = 0;
        long price = 0;

        void run()
        {
            string burger = Console.ReadLine();

            for (int i = 0; i < burger.Length; i++)
            {
                if (burger[i] == 'B') bpb++;
                if (burger[i] == 'S') spb++;
                if (burger[i] == 'C') cpb++;
            }
            string[] tokens = Console.ReadLine().Split();
            bh = int.Parse(tokens[0]);
            sh = int.Parse(tokens[1]);
            ch = int.Parse(tokens[2]);

            tokens = Console.ReadLine().Split();
            bp = int.Parse(tokens[0]);
            sp = int.Parse(tokens[1]);
            cp = int.Parse(tokens[2]);

            price = long.Parse(Console.ReadLine());

            long ox = 1;
            long nx = 2;
            if (can(1))
            {
                while (can(nx))
                {
                    ox <<= 1;
                    nx <<= 1;
                }
                long ans = ox;
                while (ox <= nx)
                {
                    long mid = (ox + nx) / 2;
                    if (can(mid))
                    {
                        ans = mid;
                        ox = mid + 1;
                    }
                    else
                    {
                        nx = mid - 1;
                    }
                }
                Console.WriteLine(ans);
            }
            else
            {
                Console.WriteLine(0);
            }

        }

        bool can(long burgers)
        {
            long cr = Math.Max(0,(cpb * burgers) - ch);
            long br = Math.Max(0,(bpb * burgers) - bh);
            long sr = Math.Max(0,(spb * burgers) - sh);
            long total = br * bp + sr * sp + cr * cp;
            return total <= price;
        }

    }

}


using System;
using System.Linq;
using System.Collections.Generic;

class Solution
{
	static void Main (string[] args)
	{
		int[] nums = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
		int n = nums [0];
		int s = nums [1];
		int target = nums [2];
		int[] v = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
		string c = Console.ReadLine ();

		List<Node> nodes = new List<Node> ();
		for (int i = 0; i < n; i++) {
			nodes.Add (new Node (i, v [i], c [i]));
		}
		nodes.ForEach (node => node.AddNeighbors (nodes));

		Node initialNode = new Node (s - 1, 0, ' ');
		initialNode.Neighbors = nodes;

		List<State>[] search = new List<State>[n * n + 2];
		for (int i = 0; i < search.Length; i++) {
			search [i] = new List<State> ();
		}
		search [0].Add (new State{ Missing = target, Current = initialNode });
		bool[,] expanded = new bool[target + 1, n];

		for (int t = 0; t < search.Length; t++) {
			foreach (State state in search[t]) {
				if (state.Solved) {
					Console.WriteLine (t - 1);
					return;
				}
				if (expanded [state.Missing, state.Current.Index])
					continue;
				expanded [state.Missing, state.Current.Index] = true;
				foreach (State s2 in state.Expand()) {
					search [s2.Time].Add (s2);
				}
			}
		}
		Console.WriteLine (-1);
	}

	class State {
		public int Missing;
		public Node Current;
		public int Time;

		public bool Solved => Missing <= 0;

		public IEnumerable<State> Expand() {
			foreach(Node n in Current.Neighbors) {
				State s = new State();
				s.Current = n;
				s.Missing = Missing - n.Value;
				s.Time = Time + Current.Dist(n);
				yield return s;
			}
		}
	}

	class Node {
		public int Index;
		public int Value;
		public char Color;
		public List<Node> Neighbors;

		public Node(int index, int value, char color) {
			this.Index = index;
			this.Value = value;
			this.Color = color;
		}

		public int Dist(Node n) {
			return Math.Abs(Index - n.Index) + (Color == ' ' ? 1 : 0);
		}

		public void AddNeighbors(List<Node> nodes) {
			Neighbors = nodes.Where (n => n.Color != this.Color && n.Value > this.Value).ToList ();
		}
	}
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

namespace Practise
{
    class Program
    {
        public static void Main()
        {
            String input = Console.ReadLine();
            String pending = Console.ReadLine();

            String left = input.Substring(0, input.IndexOf('|'));
            String right = input.Substring(input.IndexOf('|') + 1);
            int lLeft = left.Length;
            int lRight = right.Length;

            int diff = Math.Abs(lLeft - lRight);
            if (diff > pending.Length || (pending.Length - diff) % 2 != 0)
            {
                Console.WriteLine("Impossible");
            }
            else
            {
                int expLength = (lLeft + lRight + pending.Length) / 2;
                int i = 0;
                while (left.Length < expLength)
                {
                    left += pending[i++];
                }
                while (right.Length < expLength)
                {
                    right += pending[i++];
                }
                Console.WriteLine(left + "|" + right);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChallengePennants
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long n = long.Parse(s);
            if (n <= 10)
            {
                Console.WriteLine(1);
            }
            else
            {
                long x = n / 2 + n / 3 + n / 5 + n / 7;
                x -= n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35;
                x += n / 30 + n / 42 + n / 70 + n / 105;
                x -= n / 210;
                Console.WriteLine("{0:d}", n - x);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Debug = System.Diagnostics.Debug;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
namespace Solver
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var a = sc.Integer();
            var b = sc.Integer();
            var k = sc.Integer();
            const long mod = (long)1e9 + 7;
            var dp = new long[5050];
            dp[a]++;
            for (int _ = 0; _ < k; _++)
            {
                var ndp = new long[5050];
                for (int i = 1; i <= n; i++)
                {
                    if (i == b) continue;
                    var d = Math.Abs(b - i) - 1;
                    var l = Math.Max(1, i - d);
                    var r = Math.Min(n, i + d);
                    ndp[l] += dp[i];
                    ndp[i] -= dp[i];
                    ndp[i + 1] += dp[i];
                    ndp[r + 1] -= dp[i];
                }
                for (int i = 1; i <= n; i++)
                    ndp[i] = (ndp[i] + ndp[i - 1]) % mod;
                dp = ndp;
            }
            long ret = 0;
            for (int i = 1; i <= n; i++)
                ret = (ret + dp[i]) % mod;
            IO.Printer.Out.WriteLine((ret + mod) % mod);
        }
        internal IO.StreamScanner sc;
    }

    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            Debug.AutoFlush = false;
            var sw = new Watch(); sw.Start();
            try
            {
#endif
                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                solver.Solve();
                IO.Printer.Out.Flush();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

    }
    #endregion
}
#region IO Helper
namespace Solver.IO
{
    public class Printer : System.IO.StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream) { iStream = stream; }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool IsEndOfStream { get { return eof; } }
        const byte lb = 33, ub = 126, el = 10, cr = 13;
        public byte read()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b);            return (char)b; }
        public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }
        public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }
        public string Scan()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            var enc = System.Text.UTF8Encoding.Default;
            do
            {
                for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;
                if (ptr < len) break;
                ptr = 0;
                if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return ""; }
            } while (true);
            do
            {
                var f = ptr;
                for (; ptr < len; ptr++)
                    if (buf[ptr] < lb || ub < buf[ptr])
                    //if(buf[i]==cr||buf[i]==el)
                    {
                        string s;
                        if (sb == null) s = enc.GetString(buf, f, ptr - f);
                        else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }
                        ptr++; return s;
                    }
                if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));
                else sb.Append(enc.GetChars(buf, ptr, len - ptr));
                ptr = 0;

            }
            while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true; return (sb != null) ? sb.ToString() : "";
        }
        public long Long()
        {
            long ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public int Integer()
        {
            int ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }
        public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }
        public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }
        public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }
        public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }
        public void Flush() { iStream.Flush(); }
    }
}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
        static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
        static public T[] Enumerate<T>(this int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }
    }
}
#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace CF
{
    public static class FromConsole
    {
        public static T To<T>(this string input) where T : IConvertible
        {
            return (T)Convert.ChangeType(input, typeof(T));
        }

        public static T[] ToArrayOf<T>(this string input, char? delimiter = null) where T : IConvertible
        {
            IEnumerable<string> sequence = delimiter == null ? input.Select(x => x.ToString()) : input.Split(delimiter.Value);

            return sequence.Select(x => x.ToString().To<T>()).ToArray();
        }

        public static T[] ToArrayOf<T>(int count) where T : IConvertible
        {
            T[] output = new T[count];

            for (int i = 0; i < count; i++)
            {
                output[i] = Console.ReadLine().To<T>();
            }

            return output;
        }

        public static T[] ToArrayOf<T>(T value, int count)
        {
            return Enumerable.Repeat(value, count).ToArray();
        }

        public static T[][] ToMatrixOf<T>(int n, char? delimiter = null) where T : IConvertible
        {
            T[][] output = new T[n][];

            for (int i = 0; i < n; i++)
            {
                output[i] = Console.ReadLine().ToArrayOf<T>(delimiter);
            }

            return output;
        }

        public static T[][] ToMatrixOf<T>(T value, int n, int m)
        {
            T[][] output = new T[n][];

            for (int i = 0; i < n; i++)
            {
                output[i] = ToArrayOf(value, m);
            }

            return output;
        }

        public static Tuple<int, int> IndexOf<T>(this T[][] input, params T[] targets)
        {
            for (int i = 0; i < input.Length; i++)
            {
                for (int j = 0; j < input[0].Length; j++)
                {
                    if (targets.Any(x => x.Equals(input[i][j])))
                    {
                        return new Tuple<int, int>(i, j);
                    }
                }
            }

            return new Tuple<int, int>(-1, -1);
        }

        public static void AddToList<T, U>(this Dictionary<T, List<U>> input, T k, U v)
        {
            if (input.ContainsKey(k))
            {
                input[k].Add(v);
            }
            else
            {
                input.Add(k, new List<U>() { v });
            }
        }

        public static void AddAndIncrement<T>(this Dictionary<T, int> input, T k)
        {
            if (input.ContainsKey(k))
            {
                input[k]++;
            }
            else
            {
                input.Add(k, 1);
            }
        }

        public static string ToBinary(this long input)
        {
            return Convert.ToString(input, 2);
        }

        public static long ToDecimal(this string input)
        {
            return Convert.ToInt32(input, 2);
        }

        public static long Binomial(long n, long k)
        {
            long r = 1;
            long d;
            if (k > n) return 0;
            for (d = 1; d <= k; d++)
            {
                r *= n--;
                r /= d;
            }
            return r;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int n = Console.ReadLine().To<int>();
            string s = Console.ReadLine();

            char previous = ' ';
            bool duplicates = false;
            for (int i = 0; i < s.Length; i++)
            {
                char c = s[i];

                if (c == previous && c != '?')
                {
                    duplicates = true;
                    break;
                }

                previous = c;
            }

            bool canConfigure = false;
            if (!duplicates)
            {
                for (int i = 0; i < s.Length; i++)
                {
                    char c = s[i];

                    if (c == '?')
                    {
                        if (i == 0 || i == s.Length - 1)
                        {
                            canConfigure = true;
                            break;
                        }
                        else
                        {
                            char l = s[i - 1];
                            char r = s[i + 1];

                            if (l == r || l == '?' || r == '?')
                            {
                                canConfigure = true;
                                break;
                            }
                        }
                    }
                }
            }

            Console.WriteLine(canConfigure ? "Yes" : "No");
            //Console.ReadKey();
        }
    }

    //public class SegmentTreeLadder
    //{
    //    private Tuple<bool, char>[] tree;
    //    private List<int> input;

    //    public SegmentTreeLadder(List<int> input)
    //    {
    //        this.input = input;
    //        tree = new Tuple<bool, char>[4 * input.Count];
    //        Build(1, 0, input.Count - 1);
    //    }

    //    public Tuple<bool, char> RMQ(int i, int j)
    //    {
    //        return Query(1, 0, input.Count - 1, i, j);
    //    }

    //    private int Left(int p)
    //    {
    //        return 2 * p;
    //    }

    //    private int Right(int p)
    //    {
    //        return (2 * p) + 1;
    //    }

    //    private Tuple<bool, char> Compose(Tuple<bool, char> left, Tuple<bool, char> right)
    //    {
    //        if (left.Item1 && right.Item1)
    //        {
    //            if (left.Item2 == '^' && right.Item2 == 'v'
    //                || left.Item2 == '=' && right.Item2 == '='
    //                || left.Item2 == '^' && right.Item2 == '='
    //                || left.Item2 == '=' && right.Item2 == 'v')
    //            {
    //                new Tuple<bool, char>(true, '=');
    //            }

    //            // also need another char sentinel for 'mixed'
    //            // really don't need tuple, just
    //        }

    //        return new Tuple<bool, char>(false, '=');
    //    }

    //    private void Build(int p, int leftIndex, int rightIndex)
    //    {
    //        if (leftIndex == rightIndex)
    //        {
    //            // EDIT: store summarized node val here
    //            tree[p] = default(TSummary);
    //            return;
    //        }

    //        int middle = (leftIndex + rightIndex) / 2;
    //        Build(Left(p), leftIndex, middle);
    //        Build(Right(p), middle + 1, rightIndex);

    //        // EDIT: just key into tree here and get the summary of both nodes.
    //        //       this is just an access, no actual work is being done here.
    //        TSummary leftNode = tree[Left(p)];
    //        TSummary rightNode = tree[Right(p)];
    //        // EDIT: do tree[p] = f(leftIndex, rightIndex) here
    //        tree[p] = Compose(leftNode, rightNode);
    //    }

    //    private TSummary Query(int p, int leftIndex, int rightIndex, int i, int j)
    //    {
    //        // if the current segment (l, r) is outside the requested range (i, j)
    //        if (i > rightIndex || j < leftIndex)
    //        {
    //            return default(TSummary); // EDIT: should be min(T), but order would need to be defined
    //        }
    //        // if the current segment (l, r) is inside the requested range (i, j)
    //        if (i <= leftIndex && j >= rightIndex)
    //        {
    //            return tree[p];
    //        }

    //        int middle = (leftIndex + rightIndex) / 2;
    //        TSummary leftNode = Query(Left(p), leftIndex, middle, i, j);
    //        TSummary rightNode = Query(Right(p), middle + 1, rightIndex, i, j);

    //        if (leftNode.Equals(default(TSummary))) // EDIT: again, should be min(T)
    //        {
    //            return rightNode;
    //        }
    //        if (rightNode.Equals(default(TSummary))) // EDIT: again, should be min(T)
    //        {
    //            return leftNode;
    //        }

    //        return Compose(leftNode, rightNode);
    //    }
    //}

    public class SegmentTreeGeneralized<TSummary, TInput>
    {
        private TSummary[] tree;
        private List<TInput> input;

        public SegmentTreeGeneralized(List<TInput> input)
        {
            this.input = input;
            tree = new TSummary[4 * input.Count];
            Build(1, 0, input.Count - 1);
        }

        public TSummary RMQ(int i, int j)
        {
            return Query(1, 0, input.Count - 1, i, j);
        }

        private int Left(int p)
        {
            return 2 * p;
        }

        private int Right(int p)
        {
            return (2 * p) + 1;
        }

        private TSummary Compose(TSummary left, TSummary right)
        {
            return default(TSummary);
        }

        private void Build(int p, int leftIndex, int rightIndex)
        {
            if (leftIndex == rightIndex)
            {
                // EDIT: store summarized node val here
                tree[p] = default(TSummary);
                return;
            }

            int middle = (leftIndex + rightIndex) / 2;
            Build(Left(p), leftIndex, middle);
            Build(Right(p), middle + 1, rightIndex);

            // EDIT: just key into tree here and get the summary of both nodes.
            //       this is just an access, no actual work is being done here.
            TSummary leftNode = tree[Left(p)];
            TSummary rightNode = tree[Right(p)];
            // EDIT: do tree[p] = f(leftIndex, rightIndex) here
            tree[p] = Compose(leftNode, rightNode);
        }

        private TSummary Query(int p, int leftIndex, int rightIndex, int i, int j)
        {
            // if the current segment (l, r) is outside the requested range (i, j)
            if (i > rightIndex || j < leftIndex)
            {
                return default(TSummary); // EDIT: should be min(T), but order would need to be defined
            }
            // if the current segment (l, r) is inside the requested range (i, j)
            if (i <= leftIndex && j >= rightIndex)
            {
                return tree[p];
            }

            int middle = (leftIndex + rightIndex) / 2;
            TSummary leftNode = Query(Left(p), leftIndex, middle, i, j);
            TSummary rightNode = Query(Right(p), middle + 1, rightIndex, i, j);

            if (leftNode.Equals(default(TSummary))) // EDIT: again, should be min(T)
            {
                return rightNode;
            }
            if (rightNode.Equals(default(TSummary))) // EDIT: again, should be min(T)
            {
                return leftNode;
            }

            return Compose(leftNode, rightNode);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _680B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' '), input2 = Console.ReadLine().Split(' ');
            int n = int.Parse(input1[0]), a = int.Parse(input1[1]) - 1;
            bool[] t = new bool[n];
            for (int i = 0; i < n; i++) t[i] = input2[i] == "1";

            int result = 0, distance = 0;
            while (true)
            {
                bool leftExist = (a - distance) >= 0, rightExist = (a + distance) < n;
                if (!leftExist && !rightExist) break;

                if ((distance == 0 && t[a]) ||
                    (distance > 0 && leftExist && !rightExist && t[a - distance]) ||
                    (distance > 0 && !leftExist && rightExist && t[a + distance]))
                {
                    result++;
                }
                else if (distance > 0 && leftExist && rightExist && t[a - distance] && t[a + distance])
                {
                    result += 2;
                }

                distance++;
            }

            Console.WriteLine(result);
            //Console.ReadLine();
        }
    }
}