public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int q = fs.NextInt();
         long u, v, w;
         List<Edge> path;
         while (q-- > 0)
         {
             int t = fs.NextInt();
             if (t == 1)
             {
                 u = fs.NextLong();
                 v = fs.NextLong();
                 w = fs.NextLong();
                 path = GetPath(u, v);
                 foreach (var edge in path)
                 {
                     if (!costs.ContainsKey(edge)) costs.Add(edge, 0);
                     costs[edge] += w;
                 }
             }
             else
             {
                 u = fs.NextLong();
                 v = fs.NextLong();
                 path = GetPath(u, v);
                 writer.WriteLine(GetCost(path));
             }
         }
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt();
         a = new int[n];
         adjList = new LinkedList<Edge1>[n];
         for (int i = 0; i < n; i++)
         {
             adjList[i] = new LinkedList<Edge1>();
             a[i] = fs.NextInt();
         }
         for (int i = 0; i < n - 1; i++)
         {
             int p = fs.NextInt() - 1, c = fs.NextInt();
             adjList[i + 1].AddLast(new Edge1 { v = p, w = c });
             adjList[p].AddLast(new Edge1 { v = i + 1, w = c });
         }
         childNum = new int[n];
         GetChildNum(0, new bool[n]);
         long ans = VerticesToRemove(0, 0, new bool[n]);
         writer.WriteLine(ans);
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt();
         int[] rows = new int[n], cols = new int[n];
         for (int i = 0; i < n; i++)
         {
             string s = fs.ReadLine();
             for (int j = 0; j < n; j++)
             {
                 if (s[j] == 'C')
                 {
                     rows[i]++;
                     cols[j]++;
                 }
             }
         }
         long ans = 0;
         for (int i = 0; i < n; i++)
         {
             ans += (rows[i] * (rows[i] - 1)) / 2;
             ans += (cols[i] * (cols[i] - 1)) / 2;
         }
         writer.WriteLine(ans);
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int t = fs.NextInt();
         for (int i = 1; i <= t; i++)
         {
             long w = fs.NextLong();
             if ((w & 1) == 0)
             {
                 long m = 1;
                 while ((w & 1) == 0)
                 {
                     m <<= 1;
                     w >>= 1;
                 }
                 writer.WriteLine("Case " + i + ": " + w + " " + m);
             }
             else
             {
                 writer.WriteLine("Case " + i + ": Impossible");
             }
         }
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int t = fs.NextInt();
         Dictionary<string, int> count = new Dictionary<string, int>();
         while (t-- > 0)
         {
             string[] cmd = fs.ReadLine().Split();
             if (cmd[0] == "+")
             {
                 long a = Convert.ToInt64(cmd[1]);
                 string pattern = NumToPattern(a);
                 if (!count.ContainsKey(pattern)) count.Add(pattern, 0);
                 count[pattern]++;
             }
             else if (cmd[0] == "-")
             {
                 long a = Convert.ToInt64(cmd[1]);
                 string pattern = NumToPattern(a);
                 count[pattern]--;
             }
             else
             {
                 string pattern = AppendZeros(cmd[1]);
                 writer.WriteLine(count.ContainsKey(pattern) ? count[pattern] : 0);
             }
         }
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt();
         int[] indices = new int[n];
         long[] a = new long[n], b = new long[n];
         for (int i = 0; i < n; i++)
         {
             int r = fs.NextInt(), h = fs.NextInt();
             a[i] = (long)r * r * h;
             indices[i] = i;
         }
         Array.Copy(a, b, n);
         Array.Sort(b);
         for (int i = 0; i < n; i++)
         {
             indices[i] = findValue(b, 0, n - 1, a[i]);
         }
         MaxSegmentTree tree = new MaxSegmentTree(new long[n]);
         for (int i = 0; i < n; i++)
         {
             int index = indices[i];
             long value = tree.QueryMax(0, indices[i] - 1) + a[i];
             tree.Update(indices[i], indices[i], value);
         }
         writer.WriteLine((tree.QueryMax(0, n - 1) * Math.PI).ToString().Replace(',', '.'));
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt();
         LinkedList<int>[] adjList = new LinkedList<int>[n];
         for (int i = 0; i < n; i++)
         {
             adjList[i] = new LinkedList<int>();
         }
         for (int i = 0; i < n; i++)
         {
             int v = fs.NextInt() - 1;
             if (v != i) adjList[i].AddLast(v);
             if (i > 0)
             {
                 adjList[i].AddLast(i - 1);
                 adjList[i - 1].AddLast(i);
             }
         }
         int[] dist = Enumerable.Repeat(int.MaxValue, n).ToArray();
         RunDijkstra(adjList, dist);
         foreach (int x in dist)
         {
             writer.Write(x + " ");
         }
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         string str = fs.ReadLine();
         List<int> list = new List<int>(str.Length);
         int first = -1;
         for (int i = 0; i < str.Length; i++)
         {
             if (str[i] == 'F')
             {
                 if (first == -1 && list.Count != i)
                 {
                     first = list.Count;
                 }
                 list.Add(i);
             }
         }
         if (list.Count == 0 || list.Count == str.Length || first == -1)
         {
             writer.WriteLine(0);
             return;
         }
         int t = 0;
         for (int i = first + 1; i < list.Count; i++)
         {
             t = Math.Max(0, t - list[i] + list[i - 1] + 2);
         }
         writer.WriteLine(t + list.Last() - list.Count + 1);
     }
 }
        public static void Run()
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                int n = fs.NextInt(), a = fs.NextInt(), b = fs.NextInt();
                int[] p = new int[n];
                Dictionary<int, int> pos = new Dictionary<int, int>();
                Node[] nodes = new Node[n];
                for (int i = 0; i < n; i++)
                {
                    p[i] = fs.NextInt();
                    nodes[i] = new Node { Value = p[i] };
                    pos.Add(p[i], i);
                }
                for (int i = 0; i < n; i++)
                {
                    int adiff = a - nodes[i].Value;
                    int bdiff = b - nodes[i].Value;
                    if (pos.ContainsKey(adiff))
                    {
                        nodes[i].Adiff = nodes[pos[adiff]];
                        nodes[pos[adiff]].Adiff = nodes[i];
                    }
                    if (pos.ContainsKey(bdiff) && a != b)
                    {
                        nodes[i].Bdiff = nodes[pos[bdiff]];
                        nodes[pos[bdiff]].Bdiff = nodes[i];
                    }
                }

                int[] ans = Enumerable.Repeat(-1, n).ToArray();
                for (int i = 0; i < n; i++)
			    {
                    Node current = nodes[i];
                    if (!Traverse(nodes, current, pos, ans))
                    {
                        writer.WriteLine("NO");
                        return;
                    }
                }
                for (int i = 0; i < n; i++)
                {
                    Node current = nodes[i];
                    if (current.Adiff == current || current.Bdiff == current)
                    {
                        if (current.Adiff == current && current.Bdiff == null) ans[i] = 0;
                        else if (current.Adiff == current && current.Bdiff != null) current.Adiff = null;
                        else if (current.Bdiff == current && current.Adiff == null) ans[i] = 1;
                        else if (current.Bdiff == current && current.Adiff != null) current.Bdiff = null;
                    }
                    Traverse(nodes, current, pos, ans);
                }
                writer.WriteLine("YES");
                for (int i = 0; i < n; i++)
                {
                    writer.Write(ans[i] + " ");
                }
            }
        }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         long x1 = fs.NextInt(), y1 = fs.NextInt();
         long x2 = fs.NextInt(), y2 = fs.NextInt();
         int n = fs.NextInt();
         Line original = new Line 
         { 
             A = y1 - y2, 
             B = x2 - x1, 
             C = x1 * y2 - x2 * y1 
         };
         long minX = Math.Min(x1, x2), maxX = Math.Max(x1, x2);
         long minY = Math.Min(y1, y2), maxY = Math.Max(y1, y2);
         int count = 0;
         for (int i = 0; i < n; i++)
         {
             Line line = new Line { A = fs.NextInt(), B = fs.NextInt(), C = fs.NextInt() };
             double[] cross = GetIntersection(original, line);
             if (cross[0] >= minX && cross[0] <= maxX &&
                 cross[1] >= minY && cross[1] <= maxY) count++;
         }
         writer.WriteLine(count);
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         N = fs.NextInt();
         AdjList = new LinkedList<int>[N];
         for (int i = 0; i < N; i++)
         {
             AdjList[i] = new LinkedList<int>();
         }
         for (int i = 0; i < N - 1; i++)
         {
             int u = fs.NextInt() - 1, v = fs.NextInt() - 1;
             AdjList[u].AddLast(v);
             AdjList[v].AddLast(u);
         }
         int max = 0;
         foreach (int v in AdjList[0])
         {
             List<int> times = new List<int>();
             DFS(times, v, 0, 1);
             int[] temp = times.OrderBy(i => i).ToArray();
             for (int i = 1; i < temp.Length; i++)
             {
                 if (temp[i] <= temp[i - 1]) temp[i] = temp[i - 1] + 1;
             }
             max = Math.Max(max, temp[temp.Length - 1]);
         }
         writer.WriteLine(max);
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt();
         Segment[] segms = new Segment[n];
         int[] ans = new int[n];
         for (int i = 0; i < n; i++)
         {
             segms[i] = new Segment { Id = i, Left = fs.NextInt(), Right = fs.NextInt() };
         }
         segms = segms.OrderBy(s => s.Left).ToArray();
         Segment[] t = segms.OrderBy(s => s.Right).ToArray();
         int[] ind = new int[n];
         for (int i = 0; i < n; i++)
         {
             ind[i] = findItem(t, 0, n - 1, segms[i].Right);
         }
         SegmentTree tree = new SegmentTree(new int[n]);
         for (int i = n - 1; i >= 0; i--)
         {
             ans[segms[i].Id] = tree.QuerySum(0, ind[i] - 1);
             tree.Update(ind[i], ind[i], 1);
         }
         for (int i = 0; i < n; i++)
         {
             writer.WriteLine(ans[i]);
         }
     }
 }
        public static void Run()
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                int n = fs.NextInt();
                int[] a = new int[n];
                List<int[]> d = new List<int[]>();
                string s = fs.ReadLine();
                for (int i = 0; i < n; i++)
                {
                    a[i] = int.Parse("" + s[i]);
                    if (i > 0) d.Add(GetDiff(a[i - 1], a[i]));
                }

                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        if (digits[i, j] == a[0]) continue;
                        if (digits[i, j] != -1 && IsValid(i, j, d))
                        {
                            writer.WriteLine("NO");
                            return;
                        }
                    }
                }
                writer.WriteLine("YES");
            }
        }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt();
         int[] a = new int[n];
         for (int i = 0; i < n; i++)
         {
             a[i] = fs.NextInt();
         }
         for (int i = 0; i < n; i++)
         {
             for (int j = 1; j < n - i; j++)
             {
                 if (a[j] < a[j - 1])
                 {
                     int t = a[j];
                     a[j] = a[j - 1];
                     a[j - 1] = t;
                     writer.WriteLine(j + " " + (j + 1));
                 }
             }
         }
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt();
         int[] male = new int[367], fem = new int[367];
         for (int i = 0; i < n; i++)
         {
             string[] line = fs.ReadLine().Split(' ');
             if (line[0] == "M")
             {
                 int l = Convert.ToInt32(line[1]), r = Convert.ToInt32(line[2]);
                 for (int j = l; j <= r; j++) male[j]++;
             }
             else if (line[0] == "F")
             {
                 int l = Convert.ToInt32(line[1]), r = Convert.ToInt32(line[2]);
                 for (int j = l; j <= r; j++) fem[j]++;
             }
         }
         int ans = 0;
         for (int i = 1; i < 367; i++)
         {
             ans = Math.Max(ans, Math.Min(male[i], fem[i]) * 2);
         }
         writer.WriteLine(ans);
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt(), m = fs.NextInt();
         int[] a = new int[n];
         int[] accuses = new int[n], defenses = new int[n];
         bool[] isAccusing = new bool[n];
         for (int i = 0; i < n; i++)
         {
             a[i] = fs.NextInt();
             if (a[i] > 0)
             {
                 a[i] = a[i] - 1;
                 accuses[a[i]]++;
                 isAccusing[i] = true;
             }
             else
             {
                 a[i] = -a[i] - 1;
                 defenses[a[i]]++;
                 isAccusing[i] = false;
             }
         }
         bool[] isSuspect = new bool[n];
         int totalAccuses = accuses.Sum(), totalDefenses = defenses.Sum();
         int suspectCount = 0;
         for (int i = 0; i < n; i++)
         {
             if (accuses[i] + (totalDefenses - defenses[i]) == m)
             {
                 isSuspect[i] = true;
                 suspectCount++;
             }
         }
         string[] verdicts = new string[n];
         if (suspectCount == 1)
         {
             for (int i = 0; i < n; i++)
             {
                 if (isAccusing[i] && isSuspect[a[i]] || !isAccusing[i] && !isSuspect[a[i]]) verdicts[i] = "Truth";
                 else verdicts[i] = "Lie";
             }
         }
         else
         {
             for (int i = 0; i < n; i++)
             {
                 if (!isAccusing[i] && !isSuspect[a[i]]) verdicts[i] = "Truth";
                 else if (isAccusing[i] && !isSuspect[a[i]]) verdicts[i] = "Lie";
                 else verdicts[i] = "Not defined";
             }
         }
         for (int i = 0; i < n; i++)
         {
             writer.WriteLine(verdicts[i]);
         }
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt();
         int[] m = new int[n], r = new int[n];
         for (int i = 0; i < n; i++) m[i] = fs.NextInt();
         for (int i = 0; i < n; i++) r[i] = fs.NextInt();
         int size = (int)1e6;
         bool[] onDuty = new bool[size];
         for (int i = 0; i < size; i++)
         {
             for (int j = 0; j < n; j++)
             {
                 if (i % m[j] == r[j])
                 {
                     onDuty[i] = true;
                     break;
                 }
             }
         }
         int count = 0;
         for (int i = 0; i < size; i++)
         {
             if (onDuty[i]) count++;
         }
         writer.WriteLine(((count * 1.0) / size).ToString().Replace(",", "."));
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int t = fs.NextInt();
         for (int i = 1; i <= t; i++)
         {
             long s = fs.NextLong();
             long upper = (long)Math.Ceiling(Math.Sqrt(s));
             long lower = upper - 1;
             long lt = s - lower * lower, x, y;
             if ((upper & 1) == 0)
             {
                 x = Math.Min(upper, lt);
                 y = upper - (lt > upper ? (lt - upper) : 0);
             }
             else
             {
                 x = upper - (lt > upper ? (lt - upper) : 0);
                 y = Math.Min(upper, lt);
             }
             writer.WriteLine("Case " + i + ": " + x + " " + y);
         }
     }
 }
        public static void Run()
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                int n = fs.NextInt(), m = fs.NextInt();
                int[] p = new int[n];
                DisjointSet dsu = new DisjointSet();
                for (int i = 0; i < n; i++)
                {
                    p[i] = fs.NextInt() - 1;
                    dsu.MakeSet(i);
                }
                for (int i = 0; i < m; i++)
                {
                    int u = fs.NextInt() - 1, v = fs.NextInt() - 1;
                    dsu.Union(p[u], p[v]);
                }

                LinkedList<int>[] lists = new LinkedList<int>[n];
                for (int i = n - 1; i >= 0; i--)
                {
                    int set = dsu.FindSet(i);
                    if (lists[set] == null) lists[set] = new LinkedList<int>();
                    lists[set].AddLast(i);
                }
                for (int i = 0; i < n; i++)
                {
                    int set = dsu.FindSet(p[i]);
                    writer.Write(lists[set].First() + 1 + " ");
                    lists[set].RemoveFirst();
                }
            }
        }
 public static void Run()
 {
     using (FastScanner reader = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = reader.NextInt(), m = reader.NextInt();
         int[] a = new int[n], count = new int[n];
         for (int i = 0; i < n; i++)
         {
             a[i] = reader.NextInt();
         }
         count[n - 1] = 1;
         for (int i = n - 2; i >= 0; i--)
         {
             if (a[i] == a[i + 1]) count[i] = count[i + 1] + 1;
             else count[i] = 1;
         }
         while (m-- > 0)
         {
             int l = reader.NextInt() - 1, r = reader.NextInt() - 1, x = reader.NextInt(), t = l;
             if (a[l] == x) t = l + count[l];
             if (t > r) writer.WriteLine(-1);
             else writer.WriteLine(t + 1);
         }
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         long n = fs.NextLong(), k = fs.NextLong(), m = n - k;
         int p = fs.NextInt();
         while (p-- > 0)
         {
             long x = fs.NextLong() - 1;
             if (m == 0) writer.Write("X");
             else if (k == 0) writer.Write(".");
             else
             {
                 if (n % 2 == 0)
                 {
                     if (x % 2 == 0 && x <= 2 * Math.Min(m, n / 2) - 2) writer.Write(".");
                     else if (x % 2 == 1 && x <= 2 * (m - n / 2) - 1) writer.Write(".");
                     else writer.Write("X");
                 }
                 else
                 {
                     if (x % 2 == 0 && x <= 2 * Math.Min(m, (n - 1) / 2) - 2) writer.Write(".");
                     else if (x % 2 == 1 && x <= 2 * (m - (n - 1) / 2) - 1) writer.Write(".");
                     else writer.Write("X");
                 }
             }
         }
     }
 }
        public static void Run()
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                map = new Dictionary<char, int>();
                int val = 0;
                for (char c = '0'; c <= '9'; c++) map.Add(c, val++);
                for (char c = 'A'; c <= 'Z'; c++) map.Add(c, val++);
                for (char c = 'a'; c <= 'z'; c++) map.Add(c, val++);
                map.Add('-', val++);
                map.Add('_', val++);

                string s = fs.ReadLine();
                long ans = 1;
                foreach (char c in s)
                {
                    string bin = Convert.ToString(map[c], 2);
                    for (int i = bin.Length + 1; i <= 6; i++)
                    {
                        ans = (ans * 3) % 1000000007;
                    }
                    foreach (char b in bin)
                    {
                        if (b == '0') ans = (ans * 3) % 1000000007;
                    }
                }
                writer.WriteLine(ans);
            }
        }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int t = fs.NextInt();
         while (t-- > 0)
         {
             int n = fs.NextInt();
             dp = Enumerable.Repeat<long>(-1, n).ToArray();
             a = new int[n];
             sum = new long[n];
             for (int i = 0; i < n; i++)
             {
                 a[i] = fs.NextInt();
             }
             sum[n - 1] = a[n - 1];
             for (int i = n - 2; i >= 0; i--)
             {
                 sum[i] = a[i] + sum[i + 1];
             }
             for (int i = Math.Max(n - 3, 0); i < n; i++)
             {
                 for (int j = i; j < n; j++)
                 {
                     if (dp[j] == -1) dp[j] = 0;
                     dp[i] += a[j];
                 }
             }
             writer.WriteLine(Solve(0));
         }
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt(), c = fs.NextInt();
         int[] p = new int[n], t = new int[n];
         for (int i = 0; i < n; i++)
         {
             p[i] = fs.NextInt();
         }
         for (int i = 0; i < n; i++)
         {
             t[i] = fs.NextInt();
         }
         int limak = 0, radewoosh = 0, time = 0;
         for (int i = 0; i < n; i++)
         {
             time += t[i];
             limak += Math.Max(0, p[i] - c * time);
         }
         time = 0;
         for (int i = n - 1; i >= 0; i--)
         {
             time += t[i];
             radewoosh += Math.Max(0, p[i] - c * time);
         }
         writer.WriteLine(limak > radewoosh ? "Limak" : radewoosh > limak ? "Radewoosh" : "Tie");
     }
 }
        public static void Run()
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                int n = fs.NextInt(), k = fs.NextInt();
                int a = fs.NextInt(), b = fs.NextInt(), c = fs.NextInt(), d = fs.NextInt();
                if (n == 4 || k <= n) writer.WriteLine(-1);
                else
                {
                    writer.Write(a + " " + c + " ");
                    for (int i = 1; i <= n; i++)
                    {
                        if (i != a && i != b && i != c && i != d) writer.Write(i + " ");
                    }
                    writer.WriteLine(d + " " + b);

                    writer.Write(c + " " + a + " ");
                    for (int i = 1; i <= n; i++)
                    {
                        if (i != a && i != b && i != c && i != d) writer.Write(i + " ");
                    }
                    writer.Write(b + " " + d);
                }
            }
        }
        public static void Run()
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                int n = fs.NextInt();
                AdjList = new LinkedList<int>[n];
                Sizes = new int[n];
                StartTimes = new double[n];
                for (int i = 0; i < n; i++)
			    {
                    AdjList[i] = new LinkedList<int>();
			    }
                for (int i = 1; i < n; i++)
                {
                    int p = fs.NextInt() - 1;
                    AdjList[p].AddLast(i);
                }
                EvalSize(0);
                StartTimes[0] = 1;
                EvalStartTimes(0, 0);

                for (int i = 0; i < n; i++)
                {
                    writer.Write(StartTimes[i].ToString().Replace(",", ".") + " ");
                }
            }
        }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt(), h = fs.NextInt(), k = fs.NextInt();
         int[] a = new int[n];
         for (int i = 0; i < n; i++)
         {
             a[i] = fs.NextInt();
         }
         int sum = 0, j = 0;
         long sec = 0;
         while (j < n)
         {
             while (j < n && sum + a[j] <= h) sum += a[j++];
             if (j < n)
             {
                 int need = a[j] - (h - sum);
                 int s = (int)Math.Ceiling(need * 1.0 / k);
                 sec += s;
                 sum -= s * k;
                 if (sum < 0) sum = 0;
             }
             else
             {
                 sec += (int)Math.Ceiling(sum * 1.0 / k);
             }
         }
         writer.WriteLine(sec);
     }
 }
        public static void Run()
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                string[] exp = fs.ReadLine().Split('e');
                string[] num = exp[0].Split('.');

                int b = int.Parse(exp[1]);
                StringBuilder sb = new StringBuilder(200);
                sb.Append(num[0]);
                int i = 0;
                for (i = 0; i < b; i++)
                {
                    if (i >= num[1].Length) sb.Append("0");
                    else sb.Append(num[1][i]);
                }
                if (b < num[1].Length && num[1] != "0")
                {
                    sb.Append(".");
                    for (; i < num[1].Length; i++)
                    {
                        sb.Append(num[1][i]);
                    }
                }
                writer.WriteLine(sb);
            }
        }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt(), k = fs.NextInt(), q = fs.NextInt();
         User[] t = new User[n];
         List<User> d = new List<User>(k);
         for (int i = 0; i < n; i++)
         {
             t[i] = new User { Id = i, Val = fs.NextInt() };
         }
         while (q-- > 0)
         {
             int type = fs.NextInt(), id = fs.NextInt() - 1;
             if (type == 1)
             {
                 if (d.Count < k) d.Add(t[id]);
                 else
                 {
                     d = d.OrderByDescending(el => el.Val).ToList();
                     if (d.Last().Val < t[id].Val)
                     {
                         d.RemoveAt(k - 1);
                         d.Add(t[id]);
                     }
                 }
             }
             else
             {
                 writer.WriteLine(d.Contains(t[id]) ? "YES" : "NO");
             }
         }
     }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt();
         HashSet<int> set = new HashSet<int>();
         for (int i = 0; i < n; i++)
         {
             int x = fs.NextInt();
             set.Add(x);
         }
         if (set.Count < 3)
         {
             writer.WriteLine("YES");
         }
         else if (set.Count > 3)
         {
             writer.WriteLine("NO");
         }
         else
         {
             int[] a = set.ToArray();
             Array.Sort(a);
             writer.WriteLine(a[1] - a[0] == a[2] - a[1] ? "YES" : "NO");
         }
     }
 }