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

namespace Artem_and_Array
{
    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 int[] nn;

        private static void Main(string[] args)
        {
            int n = Next();
            nn = new int[n + 2];
            nn[0] = -10000000;
            for (int i = 1; i <= n; i++)
            {
                nn[i] = Next();
            }
            nn[n + 1] = -10000000;

            long count = 0;

            var points = new point[n + 2];
            var q = new Queue<point>();
            for (int i = 1; i <= n; i++)
            {
                var p = new point(i - 1, i + 1, nn[i]);
                points[i] = p;
                if (p.value >= p.current)
                {
                    q.Enqueue(p);
                    p.used = true;
                }
            }

            while (q.Count > 0)
            {
                point p = q.Dequeue();
                count += p.value;

                point p1 = points[p.left];
                point p2 = points[p.right];
                p1.right = p.right;
                p2.left = p.left;
                p1.Recalc();
                p2.Recalc();

                if (p1.value >= p1.current && !p1.used)
                {
                    q.Enqueue(p1);
                    p1.used = true;
                }
                if (p2.value >= p2.current && !p2.used)
                {
                    q.Enqueue(p2);
                    p2.used = true;
                }
            }

            var heap = new MaxBinaryHeapObject(new point(0, 0, 0));
            for (int i = 1; i <= n; i++)
            {
                if (!points[i].used)
                    heap.Add(points[i]);
            }

            while (heap.HeapSize > 2)
            {
                point p = heap.GetMax();
                count += p.value;

                point p1 = points[p.left];
                point p2 = points[p.right];
                p1.right = p.right;
                p2.left = p.left;

                p1.Recalc();
                heap.Heapify(p1);
                p2.Recalc();
                heap.Heapify(p2);
            }

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

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

        #region Nested type: MaxBinaryHeapObject

        public class MaxBinaryHeapObject
        {
            private readonly IComparer<point> _comparer;
            private readonly List<point> _list;

            public MaxBinaryHeapObject(IComparer<point> comparer)
            {
                _comparer = comparer ?? Comparer<point>.Default;
                _list = new List<point>();
            }

            public int HeapSize
            {
                get { return _list.Count; }
            }

            public void Add(point value)
            {
                _list.Add(value);
                value.where = _list.Count - 1;
                MoveUp(HeapSize - 1);
            }

            private void MoveUp(int i)
            {
                int parent = (i - 1)/2;

                while (i > 0 && _comparer.Compare(_list[parent], _list[i]) == -1)
                {
                    point temp = _list[i];
                    _list[i] = _list[parent];
                    _list[parent] = temp;

                    _list[i].where = i;
                    _list[parent].where = parent;

                    i = parent;
                    parent = (i - 1)/2;
                }
            }

            public void Heapify(point t)
            {
                MoveUp(t.where);
                MoveDown(t.where);
            }

            private void MoveDown(int i)
            {
                for (;;)
                {
                    int leftChild = 2*i + 1;
                    int rightChild = 2*i + 2;
                    int largestChild = i;

                    if (leftChild < HeapSize && _comparer.Compare(_list[leftChild], _list[largestChild]) == 1)
                    {
                        largestChild = leftChild;
                    }

                    if (rightChild < HeapSize && _comparer.Compare(_list[rightChild], _list[largestChild]) == 1)
                    {
                        largestChild = rightChild;
                    }

                    if (largestChild == i)
                    {
                        break;
                    }

                    point temp = _list[i];
                    _list[i] = _list[largestChild];
                    _list[largestChild] = temp;

                    _list[i].where = i;
                    _list[largestChild].where = largestChild;

                    i = largestChild;
                }
            }

            public point Max()
            {
                return _list[0];
            }

            public point GetMax()
            {
                point result = _list[0];
                _list[0] = _list[HeapSize - 1];
                _list[0].where = 0;
                _list.RemoveAt(HeapSize - 1);
                MoveDown(0);
                return result;
            }
        }

        #endregion

        #region Nested type: point

        public class point : IComparer<point>
        {
            public readonly int current;
            public int left;
            public int right;
            public bool used;
            public int value;
            public int where;

            public point(int left, int right, int current)
            {
                this.left = left;
                this.right = right;
                this.current = current;
                value = Math.Min(nn[left], nn[right]);
            }

            #region IComparer<point> Members

            public int Compare(point x, point y)
            {
                int c = (x.value).CompareTo(y.value);
                //if (c == 0)
                //    c = y._current.CompareTo(x._current);
                return c;
            }

            #endregion

            public void Recalc()
            {
                value = Math.Min(nn[left], nn[right]);
            }
        }

        #endregion
    }
}


n,vb,vs = gets.chomp.split(/ /).map!{|x| x.to_i}
ar = gets.chomp.split(/ /).map!{|x| x.to_i}
xu,yu = gets.chomp.split(/ /).map!{|x| x.to_i}

mint = 0
mind = 0
idx = 0
for i in 1..n-1
	wk = (ar[i]-xu).abs
	wkt = ar[i].to_f/vb+Math.sqrt(wk*wk + yu*yu)/vs
	if idx == 0 || mint > wkt
		mint = wkt
		mind = wk
		idx = i+1
	elsif mint == wkt
		if mind > wk
			mint = wkt
			mind = wk
			idx = i+1
		end
	end
end
puts idx


def koukan()
    return -1 if $sum < $aa[0]
    5.downto(1) { |i|
        return i-1 if $aa[i-1] <= $sum
    }
end

$n = gets.chomp.to_i
$sa = gets.chomp.split(/ /).map!{|x| x.to_i}
$aa = gets.chomp.split(/ /).map!{|x| x.to_i}
$sum = 0
$suma = Array.new(5).map!{|x| x = 0}
for i in 0..$n-1
    $sum += $sa[i]
    while (true)
        if $sum > $aa[4]
            wka = $sum.divmod($aa[4])
            $suma[4] += wka[0]
            $sum -= $aa[4] * wka[0]
        end
        ret = koukan()
        break if ret < 0
        $suma[ret] += 1
        $sum -= $aa[ret]
    end
end
puts $suma.join(" ")
puts $sum


include Math
require "prime"
require "bigdecimal"
require "bigdecimal/math"
require "matrix"
require "pp"
require "benchmark"

Infinity = 1/0.0
class Matrix;def inspect;empty? ? "Matrix.empty(#{row_size}, #{column_size})":"Matrix[\n#{@rows.map(&:inspect).join("\n")}\n]";end;end
def pbin(obj);case obj;when Integer;puts obj.to_s(2);end;end
class String;def to_a;split("");end;end
class String;def to_ia;split.map(&:to_i);end;end
def getia;gets.to_ia;end
def geti;gets.to_i;end
class Object;def dcopy;Marshal.load(Marshal.dump(self));end;end

n,k=getia
ar=getia
dp=Array.new(k+1).fill(0)
ar.each{|a|dp[a]+=1}
t=0
while dp[k] != n
    nextdp=Array.new(k+1).fill(0)
    for j in 0...k
        next if dp[k-j-1].zero?
        dp[k-j]+=1
        dp[k-j-1]-=1
    end
    t+=1
end
puts t


s=(gets.to_i+1)/2
a=gets(p).scan /(\S+) (.+)/
x=a.flatten.sort.each_slice([a.size/2,1].max).map(&:first).select{|i|a.count{|j,k|j==i||k==i}>=s}
p x[0]?[s-x.map{|i|a.map(&:first).count i}.max,0].max: -1


n = gets.to_i
d = gets.split.map{|i| i.to_i}
a,b = gets.split.map{|i| i.to_i}
i = a
res = 0
while i < b do
    res += d[i-1]
    i += 1
end

p res


name = gets.chomp
numb = gets.to_i

s_hash = Hash.new
arr = []
numb.times do |j|
	l = ""
	t = ""
	s = gets.chomp
	n = s.size - 1
	cnt = 0
	for i in 1..n
		if s[i] == ' '
			l = s[0,i]
			break
		end
	end
	m = l.size
	if s[m + 1,6] == "posted"
		for i in (m + 11)..n
			if s[i] == ' '
				t = s[m + 11,i - m - 13]
				break
			end
		end
		if t == name or l == name
			cnt = 15
		end
		if s_hash["#{l}"] == nil and l != name
			arr << l
		end

		if s_hash["#{t}"] == nil and t != name
			arr << t
		end

		s_hash["#{l}"] = s_hash["#{l}"].to_i + cnt
		s_hash["#{t}"] = s_hash["#{t}"].to_i + cnt
	end

	if s[m + 1,9] == "commented"
		for i in (m + 14)..n
			if s[i] == ' '
				t = s[m + 14,i - m - 16]
				break
			end
		end

		if t == name or l == name
			cnt = 10
		end
		if s_hash["#{l}"] == nil and l != name
			arr << l
		end

		if s_hash["#{t}"] == nil and t != name
			arr << t
		end

		s_hash["#{l}"] = s_hash["#{l}"].to_i + cnt
		s_hash["#{t}"] = s_hash["#{t}"].to_i + cnt
	end

		if s[m + 1,5] == "likes"
		for i in (m + 7)..n
			if s[i] == ' '
				t = s[m + 7,i - m - 9]
				break
			end
		end
		if t == name or l == name
			cnt = 5
		end
		if s_hash["#{l}"] == nil and l != name
			arr << l
		end

		if s_hash["#{t}"] == nil and t != name
			arr << t
		end

		s_hash["#{l}"] = s_hash["#{l}"].to_i + cnt
		s_hash["#{t}"] = s_hash["#{t}"].to_i + cnt
	end

end

arr.sort!

arr.sort_by! {|element| [-s_hash["#{element}"].to_i, -element] }

c = arr.size

c.times do |i|
	puts  arr[i]
end

[{'input': ["ahmed\r\n3\r\nahmed posted on fatma's wall\r\nfatma commented on ahmed's post\r\nmona likes ahmed's post\r\n"], 'output': ['fatma\r\nmona\r\n']}, {'input': ["aba\r\n1\r\nlikes likes posted's post\r\n"], 'output': ['likes\r\nposted\r\n']}, {'input': ["nu\r\n5\r\ng commented on pwyndmh's post\r\nqv posted on g's wall\r\ng likes nu's post\r\ng posted on nu's wall\r\nqv commented on pwyndmh's post\r\n"], 'output': ['g\r\npwyndmh\r\nqv\r\n']}, {'input': ["szfwtzfp\r\n5\r\nzqx posted on szfwtzfp's wall\r\nr commented on scguem's post\r\nr posted on civ's wall\r\nr likes scguem's post\r\nr likes scguem's post\r\n"], 'output': ['zqx\r\nciv\r\nr\r\nscguem\r\n']}, {'input': ["oaquudhavr\r\n3\r\ni posted on cwfwujpc's wall\r\ni likes oaquudhavr's post\r\noaquudhavr commented on cwfwujpc's post\r\n"], 'output': ['cwfwujpc\r\ni\r\n']}, {'input': ["eo\r\n4\r\neo commented on xkgjgwxtrx's post\r\neo posted on iqquh's wall\r\nn commented on xkgjgwxtrx's post\r\niqquh commented on n's post\r\n"], 'output': ['iqquh\r\nxkgjgwxtrx\r\nn\r\n']}, {'input': ["plwun\r\n3\r\neusjuq commented on plwun's post\r\nagktgdar likes eusjuq's post\r\nagppcoil likes agktgdar's post\r\n"], 'output': ['eusjuq\r\nagktgdar\r\nagppcoil\r\n']}, {'input': ["fgzrn\r\n3\r\nzhl likes fgzrn's post\r\nxryet likes fgzrn's post\r\nzhl commented on fgzrn's post\r\n"], 'output': ['zhl\r\nxryet\r\n']}, {'input': ["qatugmdjwg\r\n3\r\nb posted on cf's wall\r\nyjxkat posted on b's wall\r\nko commented on qatugmdjwg's post\r\n"], 'output': ['ko\r\nb\r\ncf\r\nyjxkat\r\n']}, {'input': ["dagwdwxsuf\r\n5\r\nesrvncb commented on dagwdwxsuf's post\r\nzcepigpbz posted on dagwdwxsuf's wall\r\nesrvncb commented on zcepigpbz's post\r\nesrvncb commented on dagwdwxsuf's post\r\ndagwdwxsuf commented on esrvncb's post\r\n"], 'output': ['esrvncb\r\nzcepigpbz\r\n']}, {'input': ["a\r\n1\r\nb likes c's post\r\n"], 'output': ['b\r\nc\r\n']}, {'input': ["a\r\n1\r\nc likes b's post\r\n"], 'output': ['b\r\nc\r\n']}, {'input': ["wuaiz\r\n10\r\nmnbggnud posted on xttaqvel's wall\r\ns posted on xopffmspf's wall\r\nkysxb likes qnrtpzkh's post\r\ngptks likes quebtsup's post\r\nkgmd commented on kmtnhsiue's post\r\newqjtxtiyn commented on a's post\r\nol posted on iglplaj's wall\r\nif posted on yuo's wall\r\nfs posted on dwjtuhgrq's wall\r\nygmdprun likes tzfneuly's post\r\n"], 'output': ['a\r\ndwjtuhgrq\r\newqjtxtiyn\r\nfs\r\ngptks\r\nif\r\niglplaj\r\nkgmd\r\nkmtnhsiue\r\nkysxb\r\nmnbggnud\r\nol\r\nqnrtpzkh\r\nquebtsup\r\ns\r\ntzfneuly\r\nxopffmspf\r\nxttaqvel\r\nygmdprun\r\nyuo\r\n']}, {'input': ["fzhzg\r\n11\r\nv likes xyf's post\r\nktqtpzhlh commented on ffsxarrn's post\r\nktqtpzhlh commented on lbt's post\r\njcdwpcycj commented on qbuigcgflm's post\r\nl likes pmg's post\r\nracszbmsk posted on ojr's wall\r\nojr commented on n's post\r\nnzqx commented on lkj's post\r\nv posted on lzoca's wall\r\nnwqnoham commented on gyivezpu's post\r\nfzhzg likes uqvzgzrpac's post\r\n"], 'output': ['uqvzgzrpac\r\nffsxarrn\r\ngyivezpu\r\njcdwpcycj\r\nktqtpzhlh\r\nl\r\nlbt\r\nlkj\r\nlzoca\r\nn\r\nnwqnoham\r\nnzqx\r\nojr\r\npmg\r\nqbuigcgflm\r\nracszbmsk\r\nv\r\nxyf\r\n']}, {'input': ["qdrnpb\r\n12\r\nymklhj commented on dkcbo's post\r\nhcucrenckl posted on mut's wall\r\nnvkyta commented on eo's post\r\npvgow likes mut's post\r\nob likes wlwcxtf's post\r\npvgow commented on advpu's post\r\nkfflyfbr commented on igozjnrxw's post\r\nsq commented on qdrnpb's post\r\nmrvn posted on lahduc's wall\r\ngsnlicy likes u's post\r\ndltqujf commented on qgzk's post\r\nr posted on bey's wall\r\n"], 'output': ['sq\r\nadvpu\r\nbey\r\ndkcbo\r\ndltqujf\r\neo\r\ngsnlicy\r\nhcucrenckl\r\nigozjnrxw\r\nkfflyfbr\r\nlahduc\r\nmrvn\r\nmut\r\nnvkyta\r\nob\r\npvgow\r\nqgzk\r\nr\r\nu\r\nwlwcxtf\r\nymklhj\r\n']}, {'input': ["biycvwb\r\n13\r\nhp likes cigobksf's post\r\nmcoqt commented on gaswzwat's post\r\nnz posted on xyvetbokl's wall\r\nqbnwy commented on ylkfbwjy's post\r\nqdwktrro likes rxgujnzecs's post\r\nbbsw commented on hwtatkfnps's post\r\ngspx posted on ugjxfnahuc's wall\r\nxlmut likes plle's post\r\numbwlleag commented on xfwlhen's post\r\nrlwxqksbwi commented on rypqtrgf's post\r\nbj posted on vovq's wall\r\nozpdpb commented on zti's post\r\nhqj posted on rxgujnzecs's wall\r\n"], 'output': ['bbsw\r\nbj\r\ncigobksf\r\ngaswzwat\r\ngspx\r\nhp\r\nhqj\r\nhwtatkfnps\r\nmcoqt\r\nnz\r\nozpdpb\r\nplle\r\nqbnwy\r\nqdwktrro\r\nrlwxqksbwi\r\nrxgujnzecs\r\nrypqtrgf\r\nugjxfnahuc\r\numbwlleag\r\nvovq\r\nxfwlhen\r\nxlmut\r\nxyvetbokl\r\nylkfbwjy\r\nzti\r\n']}, {'input': ["kmircqsffq\r\n14\r\nfrnf likes xgmmp's post\r\nfnfdpupayp commented on syz's post\r\nxefshpn commented on xgmmp's post\r\nm posted on gdwydzktok's wall\r\neskm likes pqmbnuc's post\r\npnqiapduhz likes zzqvjdz's post\r\nx likes nouuurc's post\r\nvnyxhoukuo posted on uhblapjab's wall\r\nblpjpxn likes zvwbger's post\r\nj posted on vuknetvl's wall\r\nscsw commented on xaggwxlxe's post\r\npqmbnuc commented on ojwaibie's post\r\niaazdlqdew commented on kmircqsffq's post\r\nqznqshxdi commented on umdqztoqun's post\r\n"], 'output': ['iaazdlqdew\r\nblpjpxn\r\neskm\r\nfnfdpupayp\r\nfrnf\r\ngdwydzktok\r\nj\r\nm\r\nnouuurc\r\nojwaibie\r\npnqiapduhz\r\npqmbnuc\r\nqznqshxdi\r\nscsw\r\nsyz\r\nuhblapjab\r\numdqztoqun\r\nvnyxhoukuo\r\nvuknetvl\r\nx\r\nxaggwxlxe\r\nxefshpn\r\nxgmmp\r\nzvwbger\r\nzzqvjdz\r\n']}, {'input': ["posted\r\n3\r\nposted posted on fatma's wall\r\nfatma commented on posted's post\r\nmona likes posted's post\r\n"], 'output': ['fatma\r\nmona\r\n']}, {'input': ["posted\r\n3\r\nposted posted on wall's wall\r\nwall commented on posted's post\r\nmona likes posted's post\r\n"], 'output': ['wall\r\nmona\r\n']}, {'input': ["posted\r\n3\r\nposted posted on wall's wall\r\nwall commented on posted's post\r\npost likes posted's post\r\n"], 'output': ['wall\r\npost\r\n']}, {'input': ["wall\r\n5\r\nwall posted on posted's wall\r\nwall posted on on's wall\r\nwall posted on commented's wall\r\nwall posted on likes's wall\r\nwall posted on post's wall\r\n"], 'output': ['commented\r\nlikes\r\non\r\npost\r\nposted\r\n']}, {'input': ["commented\r\n5\r\non commented on commented's post\r\npos commented on commented's post\r\nlikes commented on commented's post\r\nposted commented on commented's post\r\nwall commented on commented's post\r\n"], 'output': ['likes\r\non\r\npos\r\nposted\r\nwall\r\n']}, {'input': ["likes\r\n3\r\nlikes posted on post's wall\r\nlikes commented on on's post\r\nlikes likes commented's post\r\n"], 'output': ['post\r\non\r\ncommented\r\n']}, {'input': ["on\r\n4\r\non posted on posted's wall\r\non commented on commented's post\r\non posted on wall's wall\r\non commented on post's post\r\n"], 'output': ['posted\r\nwall\r\ncommented\r\npost\r\n']}, {'input': ["wall\r\n9\r\nwall posted on posted's wall\r\non commented on wall's post\r\nwall likes post's post\r\nposted posted on wall's wall\r\nwall commented on post's post\r\nlikes likes wall's post\r\nwall posted on on's wall\r\npost commented on wall's post\r\nwall likes likes's post\r\n"], 'output': ['posted\r\non\r\npost\r\nlikes\r\n']}, {'input': ["post\r\n9\r\npost posted on wall's wall\r\non commented on post's post\r\npost likes likes's post\r\ncommented posted on post's wall\r\npost commented on likes's post\r\nlikes likes post's post\r\npost posted on posted's wall\r\non commented on post's post\r\npost likes commented's post\r\n"], 'output': ['commented\r\nlikes\r\non\r\nposted\r\nwall\r\n']}, {'input': ["ahmed\r\n9\r\npost posted on ahmeds's wall\r\nahmeds commented on post's post\r\npost likes ahmeds's post\r\nahmeds posted on post's wall\r\npost commented on ahmeds's post\r\nahmeds likes post's post\r\npost posted on ahmeds's wall\r\nahmeds commented on post's post\r\npost likes ahmeds's post\r\n"], 'output': ['ahmeds\r\npost\r\n']}]


def ga = gets.split.map!(&:to_i)
def gi = gets.to_i
def giga = [gi, ga]
def gigs = [gi, gs]
def gs = gets.strip
def gss = gs.split
def o(x) = puts(x)
def pa(a, d = ' ') = puts(a * d)
def pan(a) = pa(a, "\n")
def yn(p) = p ? 'YES' : 'NO'
def ync(p) = p ? 'Yes' : 'No'
def hz(d = 0) = Hash.new(d)
def rqr(*a) = a.each { require _1 }
class Set def z = size end
class Array
    def r! = reverse!
    def f = first
    def l = last
    def sh = shift
    def j(...) = join(...)
    def pc = pack('c*')
    def psum!(s = 0) = map! { s += _1 }
    def lbound(x) = bsearch { _1 >= x }
    def lbound_index(x) = bsearch_index { _1 >= x }
    def hoare!(...) = shuffle!.sort!(...)
    def z = size
end
module Enumerable
    def e(...) = each(...)
    def ei(...) = each_index(...)
    def re(...) = reverse_each(...)
    def ec(...) = each_cons(...)
    def es(...) = each_slice(...)
    def wo(...) = with_object(...)
    def wi(...) = with_index(...)
    def ewi(...) = each_with_index(...)
    def ewo(...) = each_with_object(...)
    def fold(...) = reduce(...)
end
class String
    def i(...) = to_i(...)
    def e(...) = each_char(...)
    def eb(...) = each_byte(...)
    def b = bytes
    def r = reverse
    def z = size
end
class Numeric
    def f = to_f
    def i = to_i
    def s(...) = to_s(...)
    def sqrt = Math.sqrt(self)
    def isqrt = Integer.sqrt(self)
end
class Integer
    def p = pred
    def n = succ
    def t(...) = times(...)
    def popcount = loop.reduce((raise if (x = self) < 0; 0)) \
        { | r | break r if x < 1; r += x & 1; x >>= 1; r }
    def ctz = loop.reduce((raise if (x = self) <= 0; 0)) \
        { | r | break r if x[0] == 1; x >>= 1; r.n }
end
class Hash
    def ek(...) = each_key(...)
    def ev(...) = each_value(...)
    def kmin = ek.min
    def kmax = ek.max
    def vmin = ev.min
    def vmax = ev.max
    def d(...) = delete(...)
    def z = size
end
class MSet < Hash
    def <<(x) = (self[x] = (self[x] || 0).n; self)
    def d(x) = (self.delete x if (self[x] && self[x] -= 1) == 0)
end
def fio(a = 'input.txt', b = 'output.txt')
    $stdin = File.open a, 'rb'
    $stdout = File.open b, 'wb'
end
rqr 'set', 'prime'
class Set def d(...) = delete(...) end
class Prime
    def self.at_least(x) =
        loop { Prime.prime?(x) ? (break x) : x += 1 }
end
RC = /(.)\1*/

################################################################
#                                                              #
#              https://github.com/alantudyk/Stop               #
#                                                              #
################################################################

n, m = ga
r, c = 2.t.map { Hash.new { _1[_2] = hz } }
g = n.t.map do | i |
    a = gs.b
    a.ewi { r[i][_1] += 1; c[_2][_1] += 1 }
    a
end
s = []
for i in 0...n
    for j in 0...m
        x = g[i][j]
        s << x if r[i][x] < 2 && c[j][x] < 2
    end
end
o s.pc

################################################################
#                                                              #
#              https://github.com/alantudyk/Stop               #
#                                                              #
################################################################

[{'input': ['3 3\r\ncba\r\nbcd\r\ncbc\r\n'], 'output': ['abcd']}, {'input': ['5 5\r\nfcofd\r\nooedo\r\nafaoa\r\nrdcdf\r\neofsf\r\n'], 'output': ['codeforces']}, {'input': ['4 4\r\nusah\r\nusha\r\nhasu\r\nsuha\r\n'], 'output': ['ahhasusu']}, {'input': ['7 5\r\naabcd\r\neffgh\r\niijkk\r\nlmnoo\r\npqqrs\r\nttuvw\r\nxxyyz\r\n'], 'output': ['bcdeghjlmnprsuvwz']}, {'input': ['10 10\r\naaaaaaaaaa\r\nbccceeeeee\r\ncdfffffffe\r\ncdfiiiiile\r\ncdfjjjjile\r\ndddddddile\r\nedfkkkkile\r\nedddddddde\r\ngggggggggg\r\nhhhhhhhhhe\r\n'], 'output': ['b']}, {'input': ['15 3\r\njhg\r\njkn\r\njui\r\nfth\r\noij\r\nyuf\r\nyfb\r\nugd\r\nhgd\r\noih\r\nhvc\r\nugg\r\nyvv\r\ntdg\r\nhgf\r\n'], 'output': ['hkniftjfbctd']}, {'input': ['17 19\r\nbmzbmweyydiadtlcoue\r\ngmdbyfwurpwbpuvhifn\r\nuapwyndmhtqvkgkbhty\r\ntszotwflegsjzzszfwt\r\nzfpnscguemwrczqxyci\r\nvdqnkypnxnnpmuduhzn\r\noaquudhavrncwfwujpc\r\nmiggjmcmkkbnjfeodxk\r\ngjgwxtrxingiqquhuwq\r\nhdswxxrxuzzfhkplwun\r\nfagppcoildagktgdarv\r\neusjuqfistulgbglwmf\r\ngzrnyxryetwzhlnfewc\r\nzmnoozlqatugmdjwgzc\r\nfabbkoxyjxkatjmpprs\r\nwkdkobdagwdwxsufees\r\nrvncbszcepigpbzuzoo\r\n'], 'output': ['lcorviunqvgblgjfsgmrqxyivyxodhvrjpicbneodxjtfkpolvejqmllqadjwotmbgxrvs']}, {'input': ['1 1\r\na\r\n'], 'output': ['a']}, {'input': ['2 2\r\nzx\r\nxz\r\n'], 'output': ['zxxz']}, {'input': ['1 2\r\nfg\r\n'], 'output': ['fg']}, {'input': ['2 1\r\nh\r\nj\r\n'], 'output': ['hj']}, {'input': ['1 3\r\niji\r\n'], 'output': ['j']}, {'input': ['3 1\r\nk\r\np\r\nk\r\n'], 'output': ['p']}, {'input': ['2 3\r\nmhw\r\nbfq\r\n'], 'output': ['mhwbfq']}, {'input': ['3 2\r\nxe\r\ner\r\nwb\r\n'], 'output': ['xeerwb']}, {'input': ['3 7\r\nnutuvjg\r\ntgqutfn\r\nyfjeiot\r\n'], 'output': ['ntvjggqfnyfjeiot']}, {'input': ['5 4\r\nuzvs\r\namfz\r\nwypl\r\nxizp\r\nfhmf\r\n'], 'output': ['uzvsamfzwyplxizphm']}, {'input': ['8 9\r\ntjqrtgrem\r\nrwjcfuoey\r\nywrjgpzca\r\nwabzggojv\r\najqmmcclh\r\nozilebskd\r\nqmgnbmtcq\r\nwakptzkjr\r\n'], 'output': ['mrjcfuyyrjpzabzvalhozilebskdgnbtpzr']}, {'input': ['9 3\r\njel\r\njws\r\ntab\r\nvyo\r\nkgm\r\npls\r\nabq\r\nbjx\r\nljt\r\n'], 'output': ['elwtabvyokgmplabqbxlt']}, {'input': ['7 6\r\neklgxi\r\nxmpzgf\r\nxvwcmr\r\nrqssed\r\nouiqpt\r\ndueiok\r\nbbuorv\r\n'], 'output': ['eklgximpzgfvwcmrrqedoiqptdeiokuorv']}, {'input': ['14 27\r\npzoshpvvjdpmwfoeojapmkxjrnk\r\nitoojpcorxjdxrwyewtmmlhjxhx\r\ndoyopbwusgsmephixzcilxpskxh\r\nygpvepeuxjbnezdrnjfwdhjwjka\r\nrfjlbypoalbtjwrpjxzenmeipfg\r\nkhjhrtktcnajrnbefhpavxxfnlx\r\nvwlwumqpfegjgvoezevqsolaqhh\r\npdrvrtzqsoujqfeitkqgtxwckrl\r\nxtepjflcxcrfomhqimhimnzfxzg\r\nwhkfkfvvjwkmwhfgeovwowshyhw\r\nolchgmhiehumivswgtfyhqfagbp\r\ntdudrkttpkryvaiepsijuejqvmq\r\nmuratfqqdbfpefmhjzercortroh\r\nwxkebkzchupxumfizftgqvuwgau\r\n'], 'output': ['zshdanicdyldybwgclygzrhkayatwxznmicbpvlupfsoewcleploqngsyolceswtyqbpyasmuadbpcehqva']}, {'input': ['1 100\r\nysijllpanprcrrtvokqmmupuptvawhvnekeybdkzqaduotmkfwybqvytkbjfzyqztmxckizheorvkhtyoohbswcmhknyzlgxordu\r\n'], 'output': ['g']}, {'input': ['2 100\r\ngplwoaggwuxzutpwnmxhotbexntzmitmcvnvmuxknwvcrnsagvdojdgaccfbheqojgcqievijxapvepwqolmnjqsbejtnkaifstp\r\noictcmphxbrylaarcwpruiastazvmfhlcgticvwhpxyiiqokxcjgwlnfykkqdsfmrfaedzchrfzlwdclqjxvidhomhxqnlmuoowg\r\n'], 'output': ['rbe']}, {'input': ['3 100\r\nonmhsoxoexfwavmamoecptondioxdjsoxfuqxkjviqnjukwqjwfadnohueaxrkreycicgxpmogijgejxsprwiweyvwembluwwqhj\r\nuofldyjyuhzgmkeurawgsrburovdppzjiyddpzxslhyesvmuwlgdjvzjqqcpubfgxliulyvxxloqyhxspoxvhllbrajlommpghlv\r\nvdohhghjlvihrzmwskxfatoodupmnouwyyfarhihxpdnbwrvrysrpxxptdidpqabwbfnxhiziiiqtozqjtnitgepxjxosspsjldo\r\n'], 'output': ['blkck']}, {'input': ['100 1\r\na\r\nm\r\nn\r\nh\r\na\r\nx\r\nt\r\na\r\no\r\np\r\nj\r\nz\r\nr\r\nk\r\nq\r\nl\r\nb\r\nr\r\no\r\ni\r\ny\r\ni\r\np\r\ni\r\nt\r\nn\r\nd\r\nc\r\nz\r\np\r\nu\r\nn\r\nw\r\ny\r\ng\r\ns\r\nt\r\nm\r\nz\r\ne\r\nv\r\ng\r\ny\r\nj\r\nd\r\nz\r\ny\r\na\r\nn\r\nx\r\nk\r\nd\r\nq\r\nn\r\nv\r\ng\r\nk\r\ni\r\nk\r\nf\r\na\r\nb\r\nw\r\no\r\nu\r\nw\r\nk\r\nk\r\nb\r\nz\r\nu\r\ni\r\nu\r\nv\r\ng\r\nv\r\nx\r\ng\r\np\r\ni\r\nz\r\ns\r\nv\r\nq\r\ns\r\nb\r\nw\r\ne\r\np\r\nk\r\nt\r\np\r\nd\r\nr\r\ng\r\nd\r\nk\r\nm\r\nf\r\nd\r\n'], 'output': ['hlc']}, {'input': ['100 2\r\nhd\r\ngx\r\nmz\r\nbq\r\nof\r\nst\r\nzc\r\ndg\r\nth\r\nba\r\new\r\nbw\r\noc\r\now\r\nvh\r\nqp\r\nin\r\neh\r\npj\r\nat\r\nnn\r\nbr\r\nij\r\nco\r\nlv\r\nsa\r\ntb\r\nbl\r\nsr\r\nxa\r\nbz\r\nrp\r\nsz\r\noi\r\nec\r\npw\r\nhf\r\njm\r\nwu\r\nhq\r\nra\r\npv\r\ntc\r\ngv\r\nik\r\nux\r\ntz\r\nbf\r\nty\r\ndk\r\nwo\r\nor\r\nza\r\nkv\r\nqt\r\nfa\r\njy\r\nbk\r\nuv\r\ngk\r\ncz\r\nds\r\nie\r\noq\r\nmf\r\nxn\r\nql\r\nxs\r\nfb\r\niv\r\ncj\r\nkn\r\nns\r\nlg\r\nji\r\nha\r\naj\r\ndg\r\nfj\r\nut\r\nsg\r\nju\r\noc\r\nov\r\nhe\r\nnw\r\nbl\r\nlp\r\nbx\r\nnm\r\nyq\r\ncw\r\nov\r\nxk\r\npg\r\noh\r\npl\r\nuo\r\ngf\r\nul\r\n'], 'output': ['dvy']}, {'input': ['100 3\r\nruy\r\nmye\r\njgp\r\nscn\r\nktq\r\nalx\r\nmvk\r\nlpm\r\nkry\r\norb\r\nmpu\r\nzcv\r\nlge\r\nkft\r\ndzp\r\ntfb\r\nhqz\r\nuur\r\nhry\r\nzjx\r\ncuo\r\nqqc\r\ntih\r\nenj\r\nvnp\r\nbwi\r\nzzh\r\nhkc\r\nwdr\r\nldh\r\nvel\r\nizj\r\nfhb\r\nqrn\r\nqpp\r\nvzs\r\nlhg\r\nkee\r\nlbq\r\nzhy\r\nwcl\r\nyaa\r\nton\r\nfly\r\nkyw\r\nept\r\ngwq\r\ncoe\r\nopd\r\neez\r\nnmx\r\nnjg\r\nwhy\r\nvel\r\nafq\r\nnbq\r\nulx\r\noxs\r\nbbo\r\nyhx\r\nfmz\r\nnrg\r\nnfm\r\njek\r\nbeu\r\ntya\r\nxgs\r\nsgg\r\nnkq\r\nbbv\r\nwkd\r\ntns\r\nfdt\r\neox\r\nobc\r\neab\r\nkkj\r\noub\r\ngji\r\nrht\r\nozv\r\nysk\r\nsbt\r\nflf\r\npbu\r\nlxb\r\npzs\r\nrzh\r\ncea\r\nkmi\r\nuea\r\nncc\r\nzng\r\nvkn\r\njhn\r\njqw\r\nlqc\r\nmbt\r\nlov\r\ngam\r\n'], 'output': ['tvdiixs']}]


n,l = gets.chomp.split(/ /).map!{|x| x.to_i}
ar = gets.chomp.split(/ /).map!{|x| x.to_i}
ar.sort!
ar.reverse!
maxsum = 0
for j in l..ar[0]
	sum = 0
	for i in 0..ar.length-1
		if ar[i] >= j
			dv = ar[i] / j
			sum += dv * j
		end
	end
	maxsum = sum if maxsum < sum
end
puts maxsum


x, y = gets.strip.split(?.); x = x.to_i
puts x % 10 == 9 ? 'GOTO Vasilisa.' : x + (y[0] > ?4 ? 1 : 0)


def solve

    n , m = readline.split(' ')
    n = n.to_i; m = m.to_i

    s = Array.new; h = Hash.new(0)

    n.times {
        s << gets
    }

    s_ = s.dup

    (0...n).each{|x|
        s_[x] = s[x].dup
    }

    (0...n).each{|x|

        h.clear

        (0...m).each{|y|
            h[s[x][y]] += 1
        }

        (0...m).each{|y|
             s_[x][y] = '_' if (h[s[x][y]] > 1)
        }

    }

    (0...m).each{|y|

        h.clear

        (0...n).each{|x|
            h[s[x][y]] += 1
        }

        (0...n).each{|x|
             s_[x][y] = '_' if (h[s[x][y]] > 1)
        }

    }

    res = String.new

    (0...n).each{|x|
        (0...m).each{|y|
            res = res + s_[x][y].chr if (s_[x][y] != '_')
        }
    }

    return res

end

#$stdin = File.open("in.txt", "r")
puts solve

[{'input': '3 3\r\ncba\r\nbcd\r\ncbc\r\n', 'output': ['abcd']}, {'input': '5 5\r\nfcofd\r\nooedo\r\nafaoa\r\nrdcdf\r\neofsf\r\n', 'output': ['codeforces']}, {'input': '4 4\r\nusah\r\nusha\r\nhasu\r\nsuha\r\n', 'output': ['ahhasusu']}, {'input': '7 5\r\naabcd\r\neffgh\r\niijkk\r\nlmnoo\r\npqqrs\r\nttuvw\r\nxxyyz\r\n', 'output': ['bcdeghjlmnprsuvwz']}, {'input': '10 10\r\naaaaaaaaaa\r\nbccceeeeee\r\ncdfffffffe\r\ncdfiiiiile\r\ncdfjjjjile\r\ndddddddile\r\nedfkkkkile\r\nedddddddde\r\ngggggggggg\r\nhhhhhhhhhe\r\n', 'output': ['b']}, {'input': '15 3\r\njhg\r\njkn\r\njui\r\nfth\r\noij\r\nyuf\r\nyfb\r\nugd\r\nhgd\r\noih\r\nhvc\r\nugg\r\nyvv\r\ntdg\r\nhgf\r\n', 'output': ['hkniftjfbctd']}, {'input': '17 19\r\nbmzbmweyydiadtlcoue\r\ngmdbyfwurpwbpuvhifn\r\nuapwyndmhtqvkgkbhty\r\ntszotwflegsjzzszfwt\r\nzfpnscguemwrczqxyci\r\nvdqnkypnxnnpmuduhzn\r\noaquudhavrncwfwujpc\r\nmiggjmcmkkbnjfeodxk\r\ngjgwxtrxingiqquhuwq\r\nhdswxxrxuzzfhkplwun\r\nfagppcoildagktgdarv\r\neusjuqfistulgbglwmf\r\ngzrnyxryetwzhlnfewc\r\nzmnoozlqatugmdjwgzc\r\nfabbkoxyjxkatjmpprs\r\nwkdkobdagwdwxsufees\r\nrvncbszcepigpbzuzoo\r\n', 'output': ['lcorviunqvgblgjfsgmrqxyivyxodhvrjpicbneodxjtfkpolvejqmllqadjwotmbgxrvs']}, {'input': '1 1\r\na\r\n', 'output': ['a']}, {'input': '2 2\r\nzx\r\nxz\r\n', 'output': ['zxxz']}, {'input': '1 2\r\nfg\r\n', 'output': ['fg']}, {'input': '2 1\r\nh\r\nj\r\n', 'output': ['hj']}, {'input': '1 3\r\niji\r\n', 'output': ['j']}, {'input': '3 1\r\nk\r\np\r\nk\r\n', 'output': ['p']}, {'input': '2 3\r\nmhw\r\nbfq\r\n', 'output': ['mhwbfq']}, {'input': '3 2\r\nxe\r\ner\r\nwb\r\n', 'output': ['xeerwb']}, {'input': '3 7\r\nnutuvjg\r\ntgqutfn\r\nyfjeiot\r\n', 'output': ['ntvjggqfnyfjeiot']}, {'input': '5 4\r\nuzvs\r\namfz\r\nwypl\r\nxizp\r\nfhmf\r\n', 'output': ['uzvsamfzwyplxizphm']}, {'input': '8 9\r\ntjqrtgrem\r\nrwjcfuoey\r\nywrjgpzca\r\nwabzggojv\r\najqmmcclh\r\nozilebskd\r\nqmgnbmtcq\r\nwakptzkjr\r\n', 'output': ['mrjcfuyyrjpzabzvalhozilebskdgnbtpzr']}, {'input': '9 3\r\njel\r\njws\r\ntab\r\nvyo\r\nkgm\r\npls\r\nabq\r\nbjx\r\nljt\r\n', 'output': ['elwtabvyokgmplabqbxlt']}, {'input': '7 6\r\neklgxi\r\nxmpzgf\r\nxvwcmr\r\nrqssed\r\nouiqpt\r\ndueiok\r\nbbuorv\r\n', 'output': ['eklgximpzgfvwcmrrqedoiqptdeiokuorv']}, {'input': '14 27\r\npzoshpvvjdpmwfoeojapmkxjrnk\r\nitoojpcorxjdxrwyewtmmlhjxhx\r\ndoyopbwusgsmephixzcilxpskxh\r\nygpvepeuxjbnezdrnjfwdhjwjka\r\nrfjlbypoalbtjwrpjxzenmeipfg\r\nkhjhrtktcnajrnbefhpavxxfnlx\r\nvwlwumqpfegjgvoezevqsolaqhh\r\npdrvrtzqsoujqfeitkqgtxwckrl\r\nxtepjflcxcrfomhqimhimnzfxzg\r\nwhkfkfvvjwkmwhfgeovwowshyhw\r\nolchgmhiehumivswgtfyhqfagbp\r\ntdudrkttpkryvaiepsijuejqvmq\r\nmuratfqqdbfpefmhjzercortroh\r\nwxkebkzchupxumfizftgqvuwgau\r\n', 'output': ['zshdanicdyldybwgclygzrhkayatwxznmicbpvlupfsoewcleploqngsyolceswtyqbpyasmuadbpcehqva']}, {'input': '1 100\r\nysijllpanprcrrtvokqmmupuptvawhvnekeybdkzqaduotmkfwybqvytkbjfzyqztmxckizheorvkhtyoohbswcmhknyzlgxordu\r\n', 'output': ['g']}, {'input': '2 100\r\ngplwoaggwuxzutpwnmxhotbexntzmitmcvnvmuxknwvcrnsagvdojdgaccfbheqojgcqievijxapvepwqolmnjqsbejtnkaifstp\r\noictcmphxbrylaarcwpruiastazvmfhlcgticvwhpxyiiqokxcjgwlnfykkqdsfmrfaedzchrfzlwdclqjxvidhomhxqnlmuoowg\r\n', 'output': ['rbe']}, {'input': '3 100\r\nonmhsoxoexfwavmamoecptondioxdjsoxfuqxkjviqnjukwqjwfadnohueaxrkreycicgxpmogijgejxsprwiweyvwembluwwqhj\r\nuofldyjyuhzgmkeurawgsrburovdppzjiyddpzxslhyesvmuwlgdjvzjqqcpubfgxliulyvxxloqyhxspoxvhllbrajlommpghlv\r\nvdohhghjlvihrzmwskxfatoodupmnouwyyfarhihxpdnbwrvrysrpxxptdidpqabwbfnxhiziiiqtozqjtnitgepxjxosspsjldo\r\n', 'output': ['blkck']}, {'input': '100 1\r\na\r\nm\r\nn\r\nh\r\na\r\nx\r\nt\r\na\r\no\r\np\r\nj\r\nz\r\nr\r\nk\r\nq\r\nl\r\nb\r\nr\r\no\r\ni\r\ny\r\ni\r\np\r\ni\r\nt\r\nn\r\nd\r\nc\r\nz\r\np\r\nu\r\nn\r\nw\r\ny\r\ng\r\ns\r\nt\r\nm\r\nz\r\ne\r\nv\r\ng\r\ny\r\nj\r\nd\r\nz\r\ny\r\na\r\nn\r\nx\r\nk\r\nd\r\nq\r\nn\r\nv\r\ng\r\nk\r\ni\r\nk\r\nf\r\na\r\nb\r\nw\r\no\r\nu\r\nw\r\nk\r\nk\r\nb\r\nz\r\nu\r\ni\r\nu\r\nv\r\ng\r\nv\r\nx\r\ng\r\np\r\ni\r\nz\r\ns\r\nv\r\nq\r\ns\r\nb\r\nw\r\ne\r\np\r\nk\r\nt\r\np\r\nd\r\nr\r\ng\r\nd\r\nk\r\nm\r\nf\r\nd\r\n', 'output': ['hlc']}, {'input': '100 2\r\nhd\r\ngx\r\nmz\r\nbq\r\nof\r\nst\r\nzc\r\ndg\r\nth\r\nba\r\new\r\nbw\r\noc\r\now\r\nvh\r\nqp\r\nin\r\neh\r\npj\r\nat\r\nnn\r\nbr\r\nij\r\nco\r\nlv\r\nsa\r\ntb\r\nbl\r\nsr\r\nxa\r\nbz\r\nrp\r\nsz\r\noi\r\nec\r\npw\r\nhf\r\njm\r\nwu\r\nhq\r\nra\r\npv\r\ntc\r\ngv\r\nik\r\nux\r\ntz\r\nbf\r\nty\r\ndk\r\nwo\r\nor\r\nza\r\nkv\r\nqt\r\nfa\r\njy\r\nbk\r\nuv\r\ngk\r\ncz\r\nds\r\nie\r\noq\r\nmf\r\nxn\r\nql\r\nxs\r\nfb\r\niv\r\ncj\r\nkn\r\nns\r\nlg\r\nji\r\nha\r\naj\r\ndg\r\nfj\r\nut\r\nsg\r\nju\r\noc\r\nov\r\nhe\r\nnw\r\nbl\r\nlp\r\nbx\r\nnm\r\nyq\r\ncw\r\nov\r\nxk\r\npg\r\noh\r\npl\r\nuo\r\ngf\r\nul\r\n', 'output': ['dvy']}, {'input': '100 3\r\nruy\r\nmye\r\njgp\r\nscn\r\nktq\r\nalx\r\nmvk\r\nlpm\r\nkry\r\norb\r\nmpu\r\nzcv\r\nlge\r\nkft\r\ndzp\r\ntfb\r\nhqz\r\nuur\r\nhry\r\nzjx\r\ncuo\r\nqqc\r\ntih\r\nenj\r\nvnp\r\nbwi\r\nzzh\r\nhkc\r\nwdr\r\nldh\r\nvel\r\nizj\r\nfhb\r\nqrn\r\nqpp\r\nvzs\r\nlhg\r\nkee\r\nlbq\r\nzhy\r\nwcl\r\nyaa\r\nton\r\nfly\r\nkyw\r\nept\r\ngwq\r\ncoe\r\nopd\r\neez\r\nnmx\r\nnjg\r\nwhy\r\nvel\r\nafq\r\nnbq\r\nulx\r\noxs\r\nbbo\r\nyhx\r\nfmz\r\nnrg\r\nnfm\r\njek\r\nbeu\r\ntya\r\nxgs\r\nsgg\r\nnkq\r\nbbv\r\nwkd\r\ntns\r\nfdt\r\neox\r\nobc\r\neab\r\nkkj\r\noub\r\ngji\r\nrht\r\nozv\r\nysk\r\nsbt\r\nflf\r\npbu\r\nlxb\r\npzs\r\nrzh\r\ncea\r\nkmi\r\nuea\r\nncc\r\nzng\r\nvkn\r\njhn\r\njqw\r\nlqc\r\nmbt\r\nlov\r\ngam\r\n', 'output': ['tvdiixs']}]


a=[*gets.chars]
puts gets.scan(/\S/).all?{|b|(c=a.index b)&&a.delete_at(c)}?:YES:"NO"

[{'input': 'Instead of dogging Your footsteps it disappears but you dont notice anything\r\nwhere is your dog\r\n', 'output': ['NO\r\n']}, {'input': 'Instead of dogging Your footsteps it disappears but you dont notice anything\r\nYour dog is upstears\r\n', 'output': ['YES\r\n']}, {'input': 'Instead of dogging your footsteps it disappears but you dont notice anything\r\nYour dog is upstears\r\n', 'output': ['NO\r\n']}, {'input': 'abcdefg hijk\r\nk j i h g f e d c b a\r\n', 'output': ['YES\r\n']}, {'input': 'HpOKgo\r\neAtAVB\r\n', 'output': ['NO\r\n']}, {'input': 'GRZGc\r\nLPzD\r\n', 'output': ['NO\r\n']}, {'input': 'GtPXu\r\nd\r\n', 'output': ['NO\r\n']}, {'input': 'FVF\r\nr \r\n', 'output': ['NO\r\n']}, {'input': 'HpOKgo\r\nogK\r\n', 'output': ['YES\r\n']}, {'input': 'GRZGc\r\nZG\r\n', 'output': ['YES\r\n']}, {'input': 'HpOKgoueAtAVBdGffvQheJDejNDHhhwyKJisugiRAH OseK yUwqPPNuThUxTfthqIUeb wS jChGOdFDarNrKRT  MlwKecxWNoKEeD BbiHAruE XMlvKYVsJGPP\r\nAHN  XvoaNwV  AVBKwKjr u      U K wKE D K   Jy KiHsR h d W  Js IHyMPK Br iSqe  E fDA   g H\r\n', 'output': ['YES\r\n']}, {'input': 'GRZGcsLPzDrCSXhhNTaibJqVphhjbcPoZhCDUlzAbDnRWjHvxLKtpGiFWiGbfeDxBwCrdJmJGCGv GebAOinUsFrlqKTILOmxrFjSpEoVGoTdSSstJWVgMLKMPettxHASaQZNdOIObcTxtF qTHWBdNIKwj\r\nWqrxze Ji x q aT GllLrRV jMpGiMDTwwS JDsPGpAZKACmsFCOS CD Sj  bCDgKF  jJxa RddtLFAi VGLHH SecObzG q  hPF \r\n', 'output': ['YES\r\n']}, {'input': 'GtPXuwdAxNhODQbjRslDDKciOALJrCifTjDQurQEBeFUUSZWwCZQPdYwZkYbrduMijFjgodAOrKIuUKwSXageZuOWMIhAMexyLRzFuzuXqBDTEaWMzVdbzhxDGSJC SsIYuYILwpiwwcObEHWpFvHeBkWYNitqYrxqgHReHcKnHbtjcWZuaxPBVPb\r\nTQIKyqFaewOkY lZUOOuxEw EwuKcArxRQGFYkvVWIAe SuanPeHuDjquurJu aSxwgOSw jYMwjxItNUUArQjO BIujAhSwttLWp\r\n', 'output': ['YES\r\n']}, {'input': 'FVFSr unvtXbpKWF vPaAgNaoTqklzVqiGYcUcBIcattzBrRuNSnKUtmdGKbjcE\r\nUzrU K  an GFGR        Wc zt iBa     P c    T K v p     V In   b           B   c\r\n', 'output': ['YES\r\n']}, {'input': 'lSwjnYLYtDNIZjxHiTawdh ntSzggZogcIZTuiTMWVgwyloMtEhqkrOxgIcFvwvsboXUPILPIymFAEXnhApewJXJNtFyZ\r\nAoxe  jWZ u  yImg  o AZ FNI w lpj  tNhT g y  ZYcb rc J    w Dlv\r\n', 'output': ['YES\r\n']}, {'input': 'kvlekcdJqODUKdsJlXkRaileTmdGwUHWWgvgUokQxRzzbpFnswvNKiDnjfOFGvFcnaaiRnBGQmqoPxDHepgYasLhzjDgmvaFfVNEcSPVQCJKAbSyTGpXsAjIHr\r\nGjzUllNaGGKXUdYmDFpqFAKIwvTpjmqnyswWRTnxlBnavAGvavxJemrjvRJc\r\n', 'output': ['YES\r\n']}, {'input': 'kWbvhgvvoYOhwXmgTwOSCDXrtFHhqwvMlCvsuuAUXMmWaYXiqHplFZZemhgkTuvsUtIaUxtyYauBIpjdbyYxjZ ZkaBPzwqPfqF kCqGRmXvWuabnQognnkvdNDtRUsSUvSzgBuxCMBWJifbxWegsknp\r\nBsH   bWHJD n Ca T xq  PRCv  tatn Wjy sm  I q s WCjFqdWe  t W XUs  Do  eb Pfh ii  hTbF  O Fll\r\n', 'output': ['YES\r\n']}, {'input': 'OTmLdkMhmDEOMQMiW ZpzEIjyElHFrNCfFQDp SZyoZaEIUIpyCHfwOUqiSkKtFHggrTBGkqfOxkChPztmPrsHoxVwAdrxbZLKxPXHlMnrkgMgiaHFopiFFiUEtKwCjpJtwdwkbJCgA bxeDIscFdmHQJLAMNhWlrZisQrHQpvbALWTwpf jnx\r\nDbZwrQbydCdkJMCrftiwtPFfpMiwwrfIrKidEChKECxQUBVUEfFirbGWiLkFQkdJiFtkrtkbIAEXCEDkwLpK\r\n', 'output': ['YES\r\n']}, {'input': 'NwcGaIeSkOva\r\naIa\r\n', 'output': ['YES\r\n']}, {'input': 'gSrAcVYgAdbdayzbKGhIzLDjyznLRIJH KyvilAaEddmgkBPCNzpmPNeGEbmmpAyHvUSoPvnaORrPUuafpReEGoDOQsAYnUHYfBqhdcopQfxJuGXgKnbdVMQNhJYkyjiJDKlShqBTtnnDQQzEijOMcYRGMgPGVhfIReYennKBLwDTVvcHMIHMgVpJkvzTrezxqS\r\nHJerIVvRyfrPgAQMTI AqGNO mQDfDwQHKgeeYmuRmozKHILvehMPOJNMRtPTAfvKvsoGKi xHEeKqDAYmQJPUXRJbIbHrgVOMGMTdvYiLui\r\n', 'output': ['YES\r\n']}, {'input': 'ReB hksbHqQXxUgpvoNK bFqmNVCEiOyKdKcAJQRkpeohpfuqZabvrLfmpZOMcfyFBJGZwVMxiUPP pbZZtJjxhEwvrAba\r\nJTCpQnIViIGIdQtLnmkVzmcbBZR CoxAdTtWSYpbOglDFifqIVQ vfGKGtLpxpJHiHSWCMeRcrVOXBGBhoEnVhNTPWGTOErNtSvokcGdgZXbgTEtISUyTwaXUEIlJMmutsdCbiyrPZPJyRdOjnSuAGttLy\r\n', 'output': ['NO\r\n']}, {'input': 'hrLzRegCuDGxTrhDgVvM KowwyYuXGzIpcXdSMgeQVfVOtJZdkhNYSegwFWWoPqcZoeapbQnyCtojgkcyezUNHGGIZrhzsKrvvcrtokIdcnqXXkCNKjrOjrnEAKBNxyDdiMVeyLvXxUYMZQRFdlcdlcxzKTeYzBlmpNiwWbNAAhWkMoGpRxkCuyqkzXdKWwGH\r\nJESKDOfnFdxPvUOCkrgSBEPQHJtJHzuNGstRbTCcchRWJvCcveSEAtwtOmZZiW\r\n', 'output': ['NO\r\n']}, {'input': 'yDBxCtUygQwWqONxQCcuAvVCkMGlqgC zvkfEkwqbhMCQxnkwQIUhucCbVUyOBUcXvTNEGriTBwMDMfdsPZgWRgIUDqM\r\neptVnORTTyixxmWIBpSTEwOXqGZllBgSxPenYCDlFwckJlWsoVwWLAIbPOmFqcKcTcoQqahetl KLfVSyaLVebzsGwPSVbtQAeUdZAaJtfxlCEvvaRhLlVvRJhKat IaB awdqcDlrrhTbRxjEbzGwcdmdavkhcjHjzmwbxAgw\r\n', 'output': ['NO\r\n']}, {'input': 'jlMwnnotSdlQMluKWkJwAeCetcqbIEnKeNyLWoKCGONDRBQOjbkGpUvDlmSFUJ bWhohqmmIUWTlDsvelUArAcZJBipMDwUvRfBsYzMdQnPDPAuBaeJmAxVKwUMJrwMDxNtlrtAowVWqWiwFGtmquZAcrpFsLHCrvMSMMlvQUqypAihQWrFMNoaqfs IBg\r\nNzeWQ bafrmDsYlpNHSGTBBgPl WIcuNhyNaNOEFvL\r\n', 'output': ['NO\r\n']}, {'input': 'zyWvXBcUZqGqjHwZHQryBtFliLYnweXAoMKNpLaunaOlzaauWmLtywsEvWPiwxJapocAFRMjrqWJXYqfKEbBKnzLO\r\npsbi bsXpSeJaCkIuPWfSRADXdIClxcDCowwJzGCDTyAl\r\n', 'output': ['NO\r\n']}, {'input': 'kKhuIwRPLCwPFfcnsyCfBdnsraGeOCcLTfXuGjqFSGPSAeDZJSS bXKFanNqWjpFnvRpWxHJspvisDlADJBioxXNbVoXeUedoPcNEpUyEeYxdJXhGzFAmpAiHotSVwbZQsuWjIVhVaEGgqbZHIoDpiEmjTtFylCwCkWWzUOoUfOHxEZvDwNpXhBWamHn\r\nK VpJjGhNbwCRhcfmNGVjewBFpEmPlIKeTuWiukDtEWpjgqciqglkyNfWrBLbGAKvlNWxaUelJmSlSoakSpRzePvJsshOsTYrMPXdxKpaShjyVIXGhRIAdtiGpNwtiRmGTBZhkJqIMdxMHX RMxCMYcWjcjhtCHyFnCvjjezGbkRDRiVxkbh\r\n', 'output': ['NO\r\n']}, {'input': 'AXssNpFKyQmJcBdBdfkhhMUzfqJVgcLBddkwtnFSzSRUCjiDcdtmkzIGkCKSxWUEGhmHmciktJyGMkgCductyHx\r\nI nYhmJfPnvoKUiXYUBIPIcxNYTtvwPUoXERZvY ahlDpQFNMmVZqEBiYqYlHNqcpSCmhFczBlOAhsYFeqMGfqL EJsDNOgwoJfBzqijKOFcYQ\r\n', 'output': ['NO\r\n']}, {'input': 'lkhrzDZmkdbjzYKPNMRkiwCFoZsMzBQMnxxdKKVJezSBjnLjPpUYtabcPTIaDJeDEobbWHdKOdVfMQwDXzDDcSrwVenDEYpMqfiOQ xSsqApWnAMoyhQXCKFzHvvzvUvkWwmwZrvZz\r\nsUzGspYpRFsHRbRgTQuCBgnFgPkisTUfFNwyEEWWRiweWWgjRkVQxgTwxOzdsOwfrGIH O gCXpzvHzfItuEHaihmugEyymSJIogYwX qAwcwIItidfnzZDhZgQHi eRjMAeVkJHceDZuJkmxGowOsmcGYYvk Ajtgi TxwihvjLViNZjvscTWvsaQUelTSivLShhEl\r\n', 'output': ['NO\r\n']}, {'input': 'BRsVjyNhrqRHVwrJzuzRigEhdpbDmaACSPfed\r\nlWqKTjlrqOCUbgBBZdZDGCeQJDXawPnnDkQdZDgwrEQk\r\n', 'output': ['NO\r\n']}, {'input': 'KRmINuyBYPwiTsdlyiNVuylToysJKmOpcLovAtwGPqrgFJQNAYvuAiyQRkeFMECVZvkDEmTauXlyjAaYRnTJXORMZRnTakBaUzSelMilejySDIZjQjzcOIrwXdvDvpeRIkoBgreyFXIyyIZutjiEBtwrmzQtPVUhvvdEtDMbXjBpoPVjGdM EXTAK JbCnw\r\nXZZqlJvzKKtvdNlzFPDTYxidqlsgufVzyEmO FZuLQ vVQsJESNviUCovCK NwwlbxsmPtOJNmAonCqrOZ bZ LVKAsQGmoLnYjeekvEIECFk\r\n', 'output': ['NO\r\n']}]


require 'set'
n = gets.to_i
a = Set.new(gets.split(' ').map(&:to_i))
res = 0
n.times do |i|
  unless a.include?(i+1); res += 1; end;
end
p res


s, a, b = readlines.map(&:chop)
r, i = /#{a}.*#{b}/, 0
i |= 1 if s =~ r
i |= 2 if s.reverse =~ r
puts %w(fantasy forward backward both)[i]

[{'input': 'atob\r\na\r\nb\r\n', 'output': ['forward\r\n']}, {'input': 'aaacaaa\r\naca\r\naa\r\n', 'output': ['both\r\n']}, {'input': 'aaa\r\naa\r\naa\r\n', 'output': ['fantasy\r\n']}, {'input': 'astalavista\r\nastla\r\nlavista\r\n', 'output': ['fantasy\r\n']}, {'input': 'abacabadabacaba\r\nabacaba\r\nabacaba\r\n', 'output': ['both\r\n']}, {'input': 'a\r\na\r\na\r\n', 'output': ['fantasy\r\n']}, {'input': 'ab\r\nb\r\na\r\n', 'output': ['backward\r\n']}, {'input': 'aaa\r\naaaa\r\naaaa\r\n', 'output': ['fantasy\r\n']}, {'input': 'bbabbbbababbaabaabaa\r\nabb\r\nbaab\r\n', 'output': ['forward\r\n']}, {'input': 'bbbbbbbbbbbbbbbbbbbbbbbbb\r\nbbbb\r\nbbbbb\r\n', 'output': ['both\r\n']}, {'input': 'babaabababaaaababaabababaabababababababbababbbabbaabababaababbaabbababaababaaabababaabbaababaaababaa\r\nabaabababaa\r\nabaabbaa\r\n', 'output': ['forward\r\n']}, {'input': 'bbbbbbbbbbbbbbbbbbbbbbbbb\r\nbbbb\r\nbbbbb\r\n', 'output': ['both\r\n']}, {'input': 'aababaaababaabbaabababaaababaabababbaabbabaabababaabbabbbababbababababababaabababaababaaaabababaabab\r\nabaabababaa\r\nabaabbaa\r\n', 'output': ['backward\r\n']}, {'input': 'aaaa\r\naaa\r\naa\r\n', 'output': ['fantasy\r\n']}, {'input': 'zzzz\r\nzz\r\nzzz\r\n', 'output': ['fantasy\r\n']}, {'input': 'zzzz\r\nzzzz\r\nzzzz\r\n', 'output': ['fantasy\r\n']}, {'input': 'zzzz\r\nzz\r\nzz\r\n', 'output': ['both\r\n']}, {'input': 'aabaa\r\naab\r\nbaa\r\n', 'output': ['fantasy\r\n']}, {'input': 'aabaab\r\naba\r\nab\r\n', 'output': ['forward\r\n']}, {'input': 'aab\r\nb\r\naa\r\n', 'output': ['backward\r\n']}, {'input': 'abacaba\r\naca\r\nba\r\n', 'output': ['both\r\n']}]


class Kid
    attr_accessor :tied_to, :number
    def initialize (num)
        @tied_to = []
        @number = num
    end
end

result = -1
input = STDIN.gets.strip
laces = []
input.split.last.to_i.times do |i|
    laces.push STDIN.gets.strip.split.collect {|i| i.to_i}
end

while true
    kids = Array.new(input.split.first.to_i) {|i| Kid.new(i+1)}
    result += 1
    laces.each do |i|
        kids[i[0]-1].tied_to.push i[1] unless kids[i[0]-1].tied_to.include? i[1]
        kids[i[1]-1].tied_to.push i[0] unless kids[i[1]-1].tied_to.include? i[0]
    end
    remove = []
    kids.each do |i|
        remove.push(i.number) if i.tied_to.size == 1
    end
    break if remove.size == 0
    remove.each do |i|
        laces.delete_if {|l| l.include? i}
    end
end
p result


n,m=gets.chomp.split.collect{|a| a.to_i}
puts ((n-1).gcd(m-1)+1)


small_size, big_indexes = gets.chomp.split.map{|s| s.to_i}
smalls = []
small_size.times do
  array = gets.chomp.split.map{|s| s.to_i}
  array.shift
  sum = r_sum = 0
  left = right = max = -1001
  tmp = 0
  array.size.times do |i|
    sum += array[i]
    r_sum += array[-i - 1]
    left = sum if sum > left
    right = r_sum if r_sum > right
    max = array[i] if array[i] > max
    tmp += array[i]
    if tmp < 0
      tmp = 0
    else
      max = tmp if tmp > max
    end
  end
  small = {
    :sum => sum,
    :left => left,
    :right => right,
    :max => max,
  }
  smalls << small
end
max = -1001
tmp = 0
gets.chomp.split.map{|s| s.to_i}.each do |i|
  i -= 1
  max = smalls[i][:max] if smalls[i][:max] >= max
  max = tmp + smalls[i][:left] if tmp + smalls[i][:left] > max
  tmp += smalls[i][:sum]
  tmp = smalls[i][:right] if smalls[i][:right] > tmp
  tmp = 0 if tmp < 0
end
puts max


def is_jabber_id(str)
  # Check if the string matches the pattern for Jabber ID
  pattern = /^([a-zA-Z0-9_]{1,16})@(([a-zA-Z0-9_]{1,16})\.)*([a-zA-Z0-9_]{1,16})(\/([a-zA-Z0-9_]{1,16}))?$/
  if str.match?(pattern)
    return 'YES'
  else
    return 'NO'
  end
end

# Read the input
input = gets.chomp
# Call the function and print the result
puts is_jabber_id(input)

[{'input': ['mike@codeforces.com\r\n'], 'output': ['YES\r\n']}, {'input': ['john.smith@codeforces.ru/contest.icpc/12\r\n'], 'output': ['NO\r\n']}, {'input': ['test@test.ri/abacaba\r\n'], 'output': ['YES\r\n']}, {'input': ['@ops\r\n'], 'output': ['NO\r\n']}, {'input': ['this-is-the-test\r\n'], 'output': ['NO\r\n']}, {'input': ['mike@codeforces.commike@codeforces.com\r\n'], 'output': ['NO\r\n']}, {'input': ['oooop/oooop\r\n'], 'output': ['NO\r\n']}, {'input': ['w@S8/XU.5._R7fHq.@../e.WP!54Ey1L\x7f.9jv\r\n'], 'output': ['NO\r\n']}, {'input': ['lNC9D1L5U@.L!_!CcAOEEx.0z.aiW/S430sbQT\r\n'], 'output': ['NO\r\n']}, {'input': ['@/YTd.K1@lD\r\n'], 'output': ['NO\r\n']}, {'input': ['Fyi!d1l@.OesGopTnRn.81xdSb8q\x7f./MzuI\r\n'], 'output': ['NO\r\n']}, {'input': ['_TlPy65\x7fw/@.Vl@.8k\r\n'], 'output': ['NO\r\n']}, {'input': ['xpS@._s8.e0l\x7fJci/.LdiT\r\n'], 'output': ['NO\r\n']}, {'input': ['lGwo\x7f8.D2@.3\r\n'], 'output': ['NO\r\n']}, {'input': ['Ccz9T5rKZQuEerGo@6l.\r\n'], 'output': ['NO\r\n']}, {'input': ['Y@5nh@8.9P.Bx5AaY.1g.Tc_MK7.g_..0.\r\n'], 'output': ['NO\r\n']}, {'input': ['Q2/6y!SP9s\x7fG@7zIGr.Du_nR8.\r\n'], 'output': ['NO\r\n']}, {'input': ['eWfLL@gW!BEJUxF\x7fh@dghf.d4.FiYp/2.Pr7a/5O6zXdAkikjCEDrb\r\n'], 'output': ['NO\r\n']}, {'input': ['8oI/\x7fa@Q\r\n'], 'output': ['NO\r\n']}, {'input': ['J@Y9Gz550l@\x7fPqVZdQ!u\r\n'], 'output': ['NO\r\n']}, {'input': ['VTE6aTTta@DHe4xeG@6.c2R.J.O7sndWEEW.9j@.l..3Bs\r\n'], 'output': ['NO\r\n']}, {'input': ['aeo2XkK@UX.nQJN!Tg..wGN5YOi68U.oP2Yl3/\r\n'], 'output': ['NO\r\n']}, {'input': ['m13zREg8LbPr@T2.Z9@g.9u.v.A..XNH/1/tloIceXydZf3\r\n'], 'output': ['NO\r\n']}, {'input': ['4@@..f3ZT./oUGZ@\r\n'], 'output': ['NO\r\n']}, {'input': ['G.rVAxwDx@a.PVSe!KtpX4tzs/0yQGzZCPJPJoda\r\n'], 'output': ['NO\r\n']}, {'input': ['SV9T5RR425Sl0b@kzj.XT.PFWc..ho/VE7gjf\r\n'], 'output': ['NO\r\n']}, {'input': ['bgko@1../xwSj_\x7fJ\r\n'], 'output': ['NO\r\n']}, {'input': ['n5ymLC.bE@ukio.im2../.\r\n'], 'output': ['NO\r\n']}, {'input': ['zr.KB_6ZMSwI2GA5@R/4iP1ZKHpszW!YN/\r\n'], 'output': ['NO\r\n']}, {'input': ['@alK@pR\r\n'], 'output': ['NO\r\n']}, {'input': ['al_Y2I4IKp@A_N.\x7fruCw0VL/hRzJtx.S7sp/r!c.n9ffh\r\n'], 'output': ['NO\r\n']}, {'input': ['C1rE26_rTAVzLm@6@X5OGX.ibJ9./kkBEVlcU\r\n'], 'output': ['NO\r\n']}, {'input': ['feGSXP@eyUfr\x7f8.x4Re.JL.6B.r/fX_\r\n'], 'output': ['NO\r\n']}, {'input': ['Ht15T@50eo.E@.\r\n'], 'output': ['NO\r\n']}, {'input': ['k9MITs_Ar.JL2RRs4@VRq.wCuJ.6..amF.fE4.5I.6fJ7gz7\r\n'], 'output': ['NO\r\n']}, {'input': ['Mi\x7fWPE8@fc./IViqq4T4PSUuMdhH\r\n'], 'output': ['NO\r\n']}, {'input': ['pxSCmv!NbMvz2@pTQ.t!.Ntz/QEh_sl\r\n'], 'output': ['NO\r\n']}, {'input': ['s@mH@RO\x7f_/iWD\r\n'], 'output': ['NO\r\n']}, {'input': ['UP51i49wX@pvx@2LWm8w/G4M3J./9L6Szy\r\n'], 'output': ['NO\r\n']}, {'input': ['xC_5Vx8NgF..\x7fln@X1.drRTX..1vx.Xb3of@/PQYPeq@_y8!h_iF\r\n'], 'output': ['NO\r\n']}, {'input': ['qG3@LKp\r\n'], 'output': ['YES\r\n']}, {'input': ['flTq1knyb@2!Mtfss\r\n'], 'output': ['NO\r\n']}, {'input': ['/pqi7WXQPJFM4q1@hxUyUy\x7f/_pWo0n\r\n'], 'output': ['NO\r\n']}, {'input': ['zXme@.Dq.TWBs.fB.M\r\n'], 'output': ['NO\r\n']}, {'input': ['o3EaAnc3K6@h\r\n'], 'output': ['YES\r\n']}, {'input': ['G/AZdVMTzRLV4Ucm@eQ!..pq!..tRTi5.Ejkqa/HGpFYk\r\n'], 'output': ['NO\r\n']}, {'input': ['.c_V@L.1v!AFAEk7glM\x7fq.ag8Sy8@0.Qm/OLKoJpZlac\r\n'], 'output': ['NO\r\n']}, {'input': ['WKxNIM79u\x7f@I.RM\r\n'], 'output': ['NO\r\n']}, {'input': ['POTjlYcxAZsbyZPDh@sPm.z6aVaO.H1wEUhD9YvROQFUk/M_jTHS_6!\r\n'], 'output': ['NO\r\n']}, {'input': ['pbRIiuA@KZ2hVed2fMikA.@ebd.tE2Y\r\n'], 'output': ['NO\r\n']}, {'input': ['OlS_OwxYhH@im.0A7o/juNlxB\r\n'], 'output': ['YES\r\n']}, {'input': ['xkjHHDRBEFwgNP@G9TGStEs2Lu.BJge3EBXw3c9EfE\r\n'], 'output': ['YES\r\n']}, {'input': ['bK@8X7tQO.pXBHJpDewD\r\n'], 'output': ['YES\r\n']}, {'input': ['kKUXy6@0WefbXz39ywP.Q3r7uF\r\n'], 'output': ['YES\r\n']}, {'input': ['SllbRLdZ6@.T.E3x.BE2nIv.5db_.38./zgVGNjpldr\r\n'], 'output': ['NO\r\n']}, {'input': ['4lBJkY8c097oa@ZYmVbtiyyYN.gbj\r\n'], 'output': ['YES\r\n']}, {'input': ['F@JX4.SI1/0EY3XmYatfY\r\n'], 'output': ['YES\r\n']}, {'input': ['oLo01@B77Pu.9R.vtAZG0.HQSunv0J.\r\n'], 'output': ['NO\r\n']}, {'input': ['xLEctap0T@22U9W_fA/7iQeJGFu1lSgMZ\r\n'], 'output': ['YES\r\n']}, {'input': ['WYh@yUWfOQiF.gOK9k8aEa\r\n'], 'output': ['YES\r\n']}, {'input': ['BPxNVANhtEh@Oh_go.\r\n'], 'output': ['NO\r\n']}, {'input': ['mGIY@cHRNC8GlJ/2pcl3LYxpi3PaKGs\r\n'], 'output': ['YES\r\n']}, {'input': ['x6yfn7BGwqWd@.N/UXC\r\n'], 'output': ['NO\r\n']}, {'input': ['cUIr@cP.eGQC2xJXvI1X7\r\n'], 'output': ['YES\r\n']}, {'input': ['MLZ6e1vgZ4hOI@ktWk.Ro.o6C4/i8cnKHT\r\n'], 'output': ['YES\r\n']}, {'input': ['XCJIa@jFaP.Eu28YaoT9Z.Epk.Z/4TBzLWf724zE1r\r\n'], 'output': ['YES\r\n']}, {'input': ['Cz1U1xjg6iW0U@.97HoVA.YG.Qd.eI.DCXxtibi6HG.GV/0sN\r\n'], 'output': ['NO\r\n']}, {'input': ['nrKbWV@P0irxQoRxDsNvG/69WxCwCsfB\r\n'], 'output': ['YES\r\n']}, {'input': ['yI1nRv3FbuhgaI@.Y9vKe.8oc.BLi.6JfYT/tT5d36\r\n'], 'output': ['NO\r\n']}, {'input': ['IGsma3L6YTJRrXS@1g.yR3mC.c.xoCns7Wo1.9C.Oe.5ebkR/_97Ltj3\r\n'], 'output': ['YES\r\n']}, {'input': ['Uu538LDu9Bye@Gu0W0P5a.b9zA9nSaNhzB_TQ2.z/qfi5CZrH\r\n'], 'output': ['YES\r\n']}, {'input': ['bdHl525me@XzR_iO23v.YFXbnHUybbgw.i/WVEhm\r\n'], 'output': ['YES\r\n']}, {'input': ['NQsZ0K@eE8VMB.w2nYtKImB.4nUF\r\n'], 'output': ['YES\r\n']}, {'input': ['186@E.MmBaKLj.WYpt4wPZkzv93\r\n'], 'output': ['YES\r\n']}, {'input': ['hmhYxkGtWYRJFtBU@Drg3L7WKujE.lU61Ljqxv./FJ4X\r\n'], 'output': ['NO\r\n']}, {'input': ['t1RIUz9l3FA15@tOL9.rv.NjhouD.\r\n'], 'output': ['NO\r\n']}, {'input': ['_I4ytjyccT@q.WIc.Cqn\r\n'], 'output': ['YES\r\n']}, {'input': ['LwHHRYq@whOoq.e9b6i0xnoWBl7z.SGJiJe/iUij1x7\r\n'], 'output': ['YES\r\n']}, {'input': ['Yesx@9_KiJq2cBI6.\r\n'], 'output': ['NO\r\n']}, {'input': ['Zu5VFUtSbIw@ner5e\r\n'], 'output': ['YES\r\n']}, {'input': ['test@test.\r\n'], 'output': ['NO\r\n']}, {'input': ['test@.test\r\n'], 'output': ['NO\r\n']}, {'input': ['est.@test\r\n'], 'output': ['NO\r\n']}, {'input': ['test@test.ru/\r\n'], 'output': ['NO\r\n']}, {'input': ['asd@asd@\r\n'], 'output': ['NO\r\n']}, {'input': ['@\r\n'], 'output': ['NO\r\n']}, {'input': ['/\r\n'], 'output': ['NO\r\n']}, {'input': ['.\r\n'], 'output': ['NO\r\n']}, {'input': ['mike@\r\n'], 'output': ['NO\r\n']}, {'input': ['@mike\r\n'], 'output': ['NO\r\n']}, {'input': ['@mail.ru\r\n'], 'output': ['NO\r\n']}, {'input': ['test.me\r\n'], 'output': ['NO\r\n']}, {'input': ['$@ru\r\n'], 'output': ['NO\r\n']}, {'input': ['testme@o.o.o.o.o/ooooo\r\n'], 'output': ['YES\r\n']}, {'input': ['oooop/oooop\r\n'], 'output': ['NO\r\n']}, {'input': ['mail.ru/a\r\n'], 'output': ['NO\r\n']}, {'input': ['mike@mail.ru/aaa\r\n'], 'output': ['YES\r\n']}, {'input': ['mike@mike.mike\r\n'], 'output': ['YES\r\n']}]


def polygon_area(vertices)
  n = vertices.length
  sum = 0
  for i in 0...n
    j = (i+1)%n
    sum += vertices[i][0]*vertices[j][1] - vertices[j][0]*vertices[i][1]
  end
  return sum.abs/2.0
end

def sum_squares(n)
  return n*(n+1)*(2*n+1)/6
end

def solve(n, vertices)
  vertices.sort_by! {|x, y| [x, y]}
  x_values = vertices.map {|x, y| x}.uniq
  y_values = Array.new(x_values.length, 0)
  x_values.each_with_index do |x, i|
    y_values[i] = vertices.select {|vx, vy| vx == x}.map {|vx, vy| vy}.sort
  end
  total_sum = 0
  total_count = 0
  x_values.each_with_index do |x, i|
    count = y_values[i].length
    sum = y_values[i].sum
    total_sum += sum_squares(x)*(2*count-sum) + sum_squares(n-x-1)*(2*count-sum)
    total_count += count*count
  end
  return total_sum/total_count.to_f
end

lines = gets.chomp.split('\n').map {|line| line.split.map(&:to_i)}
n = lines.shift[0]
vertices = lines
puts '%.10f' % solve(n, vertices)


def find_earliest(s, forbid)
	(0...100000).each{ |i|
		s2 = (i == 0 ? "" : i.to_s) + s
		if s2.to_i >= 1989 && !forbid.include?(s2.to_i)
			return s2.to_i
		end
	}
end

n = gets.chomp.to_i

n.times {
	s = gets.chomp[4..-1]
	forbid = []
	ans = 0
	(1..s.size).each{ |i|
		ans = find_earliest(s[(-i)..-1], forbid)
		forbid.push ans
	}
	puts ans
}


def min_swaps
  n = gets.to_i
  s = gets.chomp.split('')
  tigers = s.count('T')
  hamsters = s.count('H')
  min_swaps = tigers
  s = s * 2
  (0...n).each do |i|
    tigers_in_range = s[i...(i+hamsters)].count('T')
    min_swaps = [min_swaps, tigers_in_range].min
  end
  puts min_swaps
end

min_swaps

[{'input': ['3\r\nHTH\r\n'], 'output': ['0\r\n']}, {'input': ['9\r\nHTHTHTHHT\r\n'], 'output': ['2\r\n']}, {'input': ['2\r\nTH\r\n'], 'output': ['0\r\n']}, {'input': ['4\r\nHTTH\r\n'], 'output': ['0\r\n']}, {'input': ['4\r\nHTHT\r\n'], 'output': ['1\r\n']}, {'input': ['7\r\nTTTHTTT\r\n'], 'output': ['0\r\n']}, {'input': ['8\r\nHHTHHTHH\r\n'], 'output': ['1\r\n']}, {'input': ['13\r\nHTTTHHHTTTTHH\r\n'], 'output': ['3\r\n']}, {'input': ['20\r\nTTHTHTHHTHTTHHTTTHHH\r\n'], 'output': ['4\r\n']}, {'input': ['35\r\nTTTTTTHTTHTTTTTHTTTTTTTTTTTHTHTTTTT\r\n'], 'output': ['3\r\n']}, {'input': ['120\r\nTTTTTTTHTHTHTTTTTHTHTTTTHTTTTTTTTTTTTTTTTTTTTHTTHTTTTHTTHTTTTTTTTTTTTTTTHTTTTTTHTHTTHTTTTTTHTTTTTTTTTHTTHTTTTHTTTHTTTTTH\r\n'], 'output': ['14\r\n']}, {'input': ['19\r\nHHHHHHHHHHHHHTTTHHH\r\n'], 'output': ['0\r\n']}, {'input': ['87\r\nHTHHTTHHHHTHHHHHTTTHHTHHHHTTTTHHHTTHHTHTHTHHTTHTHHTHTHTTHHHTTTTTHTTHHHHHHTHHTHHTHTTHTHH\r\n'], 'output': ['17\r\n']}, {'input': ['178\r\nTHHHTHTTTHTTHTTHHHHHTTTHTTHHTHTTTHTHTTTTTHHHTHTHHHTHHHTTTTTTTTHHHHTTHHTHHHHTHTTTHHHHHHTHHTHTTHTHTTTTTTTTTHHTTHHTHTTHHTHHHHHTTHHTTHHTTHHHTTHHTTTTHTHHHTHTTHTHTTTHHHHTHHTHHHTHTTTTTT\r\n'], 'output': ['40\r\n']}]


def find_cut_area(h, w)
    max_height = 0
    max_width = 0
    max_area = 0

    (0..30).each do |i|
        size = 2 ** i
        break if size > h

        width = [w, (size / 0.8).floor].min
        next if width < size * 0.8 || width > size * 1.25

        area = size * width
        if area > max_area
            max_area = area
            max_height = size
            max_width = width
        end
    end

    (0..30).each do |i|
        size = 2 ** i
        break if size > w

        height = [h, (size / 0.8).floor].min
        next if height < size * 0.8 || height > size * 1.25

        area = size * height
        if area > max_area || (area == max_area && height > max_height)
            max_area = area
            max_height = height
            max_width = size
        end
    end

    return max_height, max_width
end

h, w = gets.split.map(&:to_i)
height, width = find_cut_area(h, w)
puts "#{height} #{width}"


A,B,C,D=[?[,?],?(,?)].map(&:ord)
def match(c,d)
	return 1 if (c==A)&&(d==B)
	return 0 if (c==C)&&(d==D)
	false
end
t=gets.chomp
s=t.bytes.each_with_index.map.to_a
size=s.size
table=Array.new(size+1)
stack=[]
s.each{|chr|
	ord,idx=chr
	if (ord==A)||(ord==C)||stack.empty?
		stack.push chr
	else
		if m=match(stack.last.first,ord)
			_ord,_idx=stack.pop
			table[idx]=0
			table[_idx]=m
		else
			stack.push chr
		end
	end
}
max=0
sum=0
_l=l=r=0
table.each_with_index{|n,idx|
	if n
		sum+=n
	else
		if sum>max
			max=sum
			l=_l
			r=idx-1
		end
		sum=0
		_l=idx+1
	end
}
puts max
puts max==0 ? "" : t[l..r]


$numAs=Array.new(1, 0)
$numBs=Array.new(1, 0)
$numAs1=Array.new(1, 0)
$numBs1=Array.new(1, 0)

def f(a, b, c, d)
    nA=[b-a+1, $numAs[b]].min
    nB=$numBs[b]-$numBs[a-1]
    nA1=[d-c+1, $numAs1[d]].min
    nB1=$numBs1[d]-$numBs1[c-1]
#    print nA, nB, nA1, nB1, "\n"
    if (nB==nB1)
        if (nA>=nA1 && (nA%3)==(nA1%3))
            print 1
        else
            print 0
        end
    elsif (nB<nB1 && (nB%2)==(nB1%2))
        if (nB==0)
            nA-=1
        end
        if (nA>=nA1)
            print 1
        else
            print 0
        end
    else
        print 0
    end
end

s=gets
s1=gets
n=gets.to_i
(0..s.length-1).each{|x| $numBs.push($numBs[x]+(s[x]=="B" || s[x]=="C" ? 1 : 0 ))}
(0..s1.length-1).each{|x| $numBs1.push($numBs1[x]+(s1[x]=="B" || s1[x]=="C" ? 1 : 0 ))}
(0..s.length-1).each{|x| $numAs.push(s[x]=='A' ? $numAs[x]+1 : 0)}
(0..s1.length-1).each{|x| $numAs1.push(s1[x]=='A' ? $numAs1[x]+1 : 0)}
t=Array.new
for i in 0...n
  t=gets.split(' ').collect{|x| x.to_i}
  f(t[0], t[1], t[2], t[3])
end


s = gets.chomp!
mods = 1000000007
dp = [[0,0,0],[0,0,0]]

len =s.size
cur =0;nxt=1;

case s[0]
when '0'
	dp[cur][0]=1
when '1'
	dp[cur][1]=1
when '2'
	p 0
	exit
when '*'
	dp[cur][2]=1
when '?'
	dp[cur][0]=dp[cur][1]=dp[cur][2]=1
end

for i in 1...len
	case s[i]
	when '0'
		dp[nxt][0]=dp[cur][0]
	when '1'
		dp[nxt][1]= dp[cur][0]
		dp[nxt][0]= dp[cur][2]
	when '2'
		dp[nxt][1]=dp[cur][2]
	when '*'
		dp[nxt][2]= (dp[cur][1]+dp[cur][2])%mods
	when '?'
		dp[nxt][1]= (dp[cur][2]+dp[cur][0])%mods
		dp[nxt][0]= (dp[cur][0]+dp[cur][2])%mods
		dp[nxt][2]= (dp[cur][1]+dp[cur][2])%mods
	end
	cur = nxt
	nxt = cur==0?1:0
	dp[nxt] = [0,0,0]
end

puts "#{(dp[cur][0]+dp[cur][2])%mods}"


def min(x, lim)
  (lim.."2011").each do |s|
    d = 0
    for i in 0..3
       d += (s[i] == x[i]) ? 0 : 1
    end
    next if d > 1

    return s
  end

  return false
end

lim = "1000"
o = []
gets.to_i.times do
  s = gets.chomp
  r = min(s, lim)
  unless r
    puts "No solution"
    exit
  end
  o << r
  lim = r
end
puts o


k=gets.split[1].to_i
a=gets.split[0].bytes.to_a
n=a.length
cnt=Array.new(10,0)
n.times{|i|
    a[i]-=48
    cnt[a[i]]+=1
}
mincost=99999999
res=[]
10.times{|d|
    cost=0
    count=cnt[d]
    1.upto(9){|i|
        if count>=k then
            break
        end
        if d+i<=9 then
            if cnt[d+i]+count>=k then
                cost+=i*(k-count)
                count=k
            else
                count+=cnt[d+i]
                cost+=cnt[d+i]*i
            end
        end
        if d-i>=0 then
            if cnt[d-i]+count>=k then
                cost+=i*(k-count)
                count=k
            else
                count+=cnt[d-i]
                cost+=cnt[d-i]*i
            end
        end
    }
    if cost<mincost then
        mincost=cost
        res=[]
    end
    if cost==mincost then
        ans=Array.new(n,0)
        used=Array.new(n,0)
        count=0
        0.upto(9){|i|
            tar=d+i
            n.times{|j|
                if count>=k then
                    break
                end
                if used[j]==0 && a[j]==tar then
                    ans[j]=d
                    count+=1
                    used[j]=true
                end
            }
            tar=d-i
            (n-1).downto(0){|j|
                if count>=k then
                    break
                end
                if used[j]==0 && a[j]==tar then
                    ans[j]=d
                    count+=1
                    used[j]=true
                end
            }
        }
        n.times{|j|
            if used[j]==0 then
                ans[j]=a[j]
            end
        }
        res.push(ans)
    end
}
puts mincost
ans=res.min
ans.each{|i| print i}
puts


gets
s,ans=[],0
gets.split.map(&:to_i).each do |i|
  while s[-2]&&(k=[s[-2],i].min)>=s[-1]
    ans+=k
    s.pop
  end
  s.push i
end
s.sort!
(0..s.size-3).each{|i| ans+=s[i]}
p ans


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	n, m := readTwoNums(reader)
	price := readNNums(reader, n)
	E := make([][]int, m)
	for i := 0; i < m; i++ {
		E[i] = readNNums(reader, 2)
	}
	res := solve(price, E)
	fmt.Println(res)
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func solve(price []int, E [][]int) int {
	n := len(price)

	A := make([][]bool, n)
	for i := 0; i < n; i++ {
		A[i] = make([]bool, n)
	}

	for _, e := range E {
		u, v := e[0], e[1]
		u--
		v--
		A[u][v] = true
		A[v][u] = true
	}

	res := -1

	for u := 0; u < n; u++ {
		for v := u + 1; v < n; v++ {
			if A[u][v] {
				for w := 0; w < n; w++ {
					if A[u][w] && A[w][v] {
						if res < 0 || price[u]+price[v]+price[w] < res {
							res = price[u] + price[v] + price[w]
						}
					}
				}
			}
		}
	}

	return res
}


package main

import (
  "os"
  "bufio"
  "strconv"
  "fmt"
)

func scanInt64(scanner *bufio.Scanner) int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}

func main() {
  scanner := bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()
  n, x, y := scanInt64(scanner), scanInt64(scanner), scanInt64(scanner)
  a := y - n + 1
  s := a*a + n - 1
  if a >= 1 && s >= x {
    writer.WriteString(fmt.Sprintf("%d\n", a))
    for i := int64(1); i < n; i++ {
      writer.WriteString("1\n")
    }
  } else {
    writer.WriteString("-1\n")
  }
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	n, vb, vs := readThreeNums(reader)
	X := readNNums(reader, n)
	room := readNNums(reader, 2)

	fmt.Println(solve(n, vb, vs, X, room))
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int, vb int, vs int, X []int, exam []int) int {
	time := make([]float64, n)
	v1 := float64(vs)
	v2 := float64(vb)
	var best = math.MaxFloat64
	for i := 0; i < n; i++ {
		t1 := float64(X[i]) / v2
		t2 := distance(exam[0], exam[1], X[i], 0) / v1
		time[i] = t1 + t2
		if i > 0 && time[i] < best {
			best = time[i]
		}
	}
	var pos int

	var dist = math.MaxFloat64
	for i := 0; i < n; i++ {
		if math.Abs(time[i]-best) < 1e-9 {
			tmp := distance(exam[0], exam[1], X[i], 0)
			if tmp < dist {
				dist = tmp
				pos = i
			}
		}
	}

	return pos + 1
}

func distance(a, b, c, d int) float64 {
	dx := float64(c - a)
	dy := float64(d - b)
	return math.Sqrt(dx*dx + dy*dy)
}


// A2. Good Matrix Elements
/*
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good:

    Elements of the main diagonal.
    Elements of the secondary diagonal.
    Elements of the "middle" row — the row which has exactly rows above it and the same number of rows below it.
    Elements of the "middle" column — the column that has exactly columns to the left of it and the same number of columns to the right of it.

The figure shows a 5 × 5 matrix. The good elements are marked with green.

Help the Smart Beaver count the sum of good elements of the given matrix.

Input

The first line of input data contains a single odd integer n. Each of the next n lines contains n integers a ij (0 ≤ a ij ≤ 100) separated by single spaces — the elements of the given matrix.

The input limitations for getting 30 points are:

    1 ≤ n ≤ 5

The input limitations for getting 100 points are:

    1 ≤ n ≤ 101

Output
Print a single integer — the sum of good matrix elements.

Examples
Input
3
1 2 3
4 5 6
7 8 9

Output
45

Input
5
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1

Output
17

Note
In the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
*/
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	n, _ := strconv.Atoi(strings.TrimSpace(input1))

	total := 0
	for i := 0; i < n; i++ {
		input2, _ := reader.ReadString('\n')
		for j := 0; j < n; j++ {
			arr := strings.Split(strings.TrimSpace(input2), " ")
			x, _ := strconv.Atoi(arr[j])
			if i == j {
				total += x
			} else if i+j == n-1 {
				total += x
			} else if j == (n-1)/2 {
				total += x
			} else if i == (n-1)/2 {
				total += x
			}
		}
	}
	fmt.Print(total)
}


package main

import (
  "os"
  "bufio"
  "strings"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

type Key struct {
  R, C int
  Ch rune
}

func main() {
  reader := bufio.NewReader(os.Stdin)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  var n, m, x int
  line, _ := reader.ReadString('\n')
  fmt.Sscanf(line, "%d %d %d", &n, &m, &x)
  keys := []Key{}
  for r := 0; r < n; r++ {
    line, _ := reader.ReadString('\n')
    s := strings.TrimSpace(line)
    for c, ch := range s {
      keys = append(keys, Key{ r, c, ch })
    }
  }
  cost := map[rune]int{}
  for i := 0; i < len(keys); i++ {
    a := keys[i]
    if a.Ch != 'S' {
      cost[a.Ch] = 1
      continue
    }
    for j := 0; j < len(keys); j++ {
      b := keys[j]
      if b.Ch != 'S' {
        ch := b.Ch - 'a' + 'A'
        if cost[ch] == 1 {
          continue
        }
        cost[ch] = 2
        d2 := (a.R - b.R)*(a.R - b.R) + (a.C - b.C)*(a.C - b.C)
        if d2 <= x*x {
          cost[ch] = 1
        }
      }
    }
  }
  reader.ReadString('\n')
  line, _ = reader.ReadString('\n')
  s := strings.TrimSpace(line)
  result := 0
  for _, ch := range s {
    c, found := cost[ch]
    if !found {
      writer.WriteString("-1\n")
      return
    }
    result += c-1
  }
  writer.WriteString(fmt.Sprintf("%d\n", result))
}

[{'input': ['2 2 1\r\nab\r\ncd\r\n1\r\nA\r\n'], 'output': ['-1\r\n']}, {'input': ['2 2 1\r\nab\r\ncd\r\n1\r\ne\r\n'], 'output': ['-1\r\n']}, {'input': ['2 2 1\r\nab\r\ncS\r\n5\r\nabcBA\r\n'], 'output': ['1\r\n']}, {'input': ['3 9 4\r\nqwertyuio\r\nasdfghjkl\r\nSzxcvbnmS\r\n35\r\nTheQuIcKbRoWnFOXjummsovertHeLazYDOG\r\n'], 'output': ['2\r\n']}, {'input': ['10 9 3\r\noboxlgpey\r\nyxcuwkkmp\r\njuqeflhwq\r\nsfnxqtjqS\r\nkkudcnyjl\r\nhgjlcrkjq\r\njnofqksxn\r\nqbhsnuguv\r\nlvahnifao\r\nebwnnlrwe\r\n35\r\nCodeforcesBetaRoundproblemAtestfive\r\n'], 'output': ['4\r\n']}, {'input': ['2 7 4\r\niuqtieo\r\nysxcgmS\r\n2\r\nsQ\r\n'], 'output': ['1\r\n']}, {'input': ['1 2 4\r\nbS\r\n8\r\nbBbbbBbb\r\n'], 'output': ['0\r\n']}, {'input': ['7 8 5\r\nfqiubjpm\r\nqbshcsyk\r\ncjbxpbef\r\nptwpmapx\r\nryazscbm\r\nqnvsgzrf\r\nhtardzkz\r\n9\r\nuxrmwkayy\r\n'], 'output': ['0\r\n']}, {'input': ['8 6 4\r\nefvmov\r\nkeofnw\r\npwajpe\r\nknptky\r\nSibruu\r\nrgdukk\r\nbsxosd\r\nhovgSe\r\n10\r\nECreruXmsC\r\n'], 'output': ['-1\r\n']}, {'input': ['10 3 2\r\nukk\r\neqt\r\nfex\r\nqSh\r\ntvz\r\nfjn\r\niol\r\nehd\r\nnte\r\ngyx\r\n5\r\ncgQxI\r\n'], 'output': ['-1\r\n']}, {'input': ['10 10 19\r\nowqjcaSpqn\r\nvgrhboqahn\r\nbzziocjmbu\r\npurqsmiSop\r\nxcsifctjhy\r\nycyytwoamk\r\nrnjfxsxowl\r\nnkgcywcdff\r\nbazljrisqv\r\nkcakigSekq\r\n100\r\nzewpATtssQVicNrlRrcoifTutTAfFMUEfDFKoNyQbSrSYxTGMadNkRpmJvoEqUsqPYgAdQreaUrwDKMNFWiwdRRCcJBPorfMVMoK\r\n'], 'output': ['0\r\n']}, {'input': ['10 10 26\r\nwxmssptheb\r\nzpxbxsyxsy\r\nqbjkpaywqp\r\nfwhnuzjcgq\r\nycgaanzedz\r\njrycrbzqfs\r\ngswwakybus\r\nfhtxhljedz\r\noSepmyjosv\r\ndwviycevdn\r\n100\r\nyapwUfnyPzgZyFvAHGKWVbXQHkuhJDoUTvCAtdMMCQmKchxKkilUTECOqYJFUSHPqKiRKhDXZgHxwApDWlShdwakmVCgaeKCLOMX\r\n'], 'output': ['0\r\n']}, {'input': ['10 10 3\r\nrvouufmnqu\r\nbyukrnmnhr\r\nzjggwxgvkz\r\ntcagkSitiw\r\nhryajgtpwc\r\njragfhqoks\r\nkgroxxkuvp\r\nbpgrkqiyns\r\njbuhjjkziw\r\nomjmbaggsw\r\n100\r\nCpRzrPqPngYvrVJFCWRPMRwrpXcbtiwfoFcAkRaNjzpMMKOQAzBxSrxGbIHaYgmSqhhxhZTmhFttKnhFzRfKxYXshUZRvtKJIzZq\r\n'], 'output': ['12\r\n']}, {'input': ['10 10 2\r\nfriuxvShvg\r\nerslojqtgu\r\nzeqsmdewry\r\nwvhbeeyeSu\r\ngkofbjaavr\r\ntwkcdxugps\r\nnzlylSmafu\r\nstamkpxnzt\r\nuwxwximkrm\r\nmzxyboazbl\r\n100\r\nmRIfAtrLKmztpVkAmojDCiIgseBwlUilBIixDQhqNhNAqVLLIobuCIretLdSvixNNdCiouFMXtwHZFlObCeaygmIiFBfaCirbmCa\r\n'], 'output': ['19\r\n']}, {'input': ['10 10 2\r\nbddahSqkmk\r\npxbocxayjs\r\nottvdazstk\r\nlaxuidqlqb\r\nkfjwdpdfat\r\nxlipuubkgv\r\niqyomzfktm\r\niwbgidmwyu\r\nrngqkeupsf\r\nbqndtekryw\r\n100\r\nMNQgWFLhHycqwjSsbTkbgMYAIHFYARRmOsinYMFjOxxnLjiKfeiBbMpoeTdzUMORPaAxRNfvdAPFaKkPdxdAjjJgGCxkDzmSasqq\r\n'], 'output': ['37\r\n']}, {'input': ['10 10 2\r\nnxcwdrsmrv\r\nSyjahsosvp\r\nvkrqbxhgbv\r\nwkxywavtnn\r\nepkyoviqbi\r\nsfmpvhuwwq\r\nnlsostrotx\r\ntcdguorhny\r\nimixrqzSdu\r\nxzhdhdwibt\r\n100\r\nUzzaWiRFYbAqxIDMrRBBDoGQhSzSqSLEddAiJsZcxbemdeuddamNYdWOvzlYSCuHIRpnuxdNxAsnZMiLXBYwnrMcrbNeLrUYhZOB\r\n'], 'output': ['17\r\n']}, {'input': ['10 10 23\r\nhtyvouoiqi\r\nvySvsfqadv\r\nxvqyqjyutq\r\npjcrrphzbk\r\nhlqfyoqfmo\r\nezcSwleoew\r\nxkwqrajxyg\r\nngSiftgoso\r\njyndgicccr\r\nlgjvokydhp\r\n100\r\nJzVVfotldIRcyjhTNRcFlTxFeZKRwavZxYcvdDOQyUvTmryFRuRBcRvmscegtspkPuchqlFEKbrfpTOSlSFOARsbbvSenMwNmaRj\r\n'], 'output': ['0\r\n']}, {'input': ['10 10 7\r\nifcwalsdbj\r\njpykymrbei\r\nrylzgkyefh\r\noilvvexpjp\r\niptgodpfim\r\ndSrqejaixu\r\npksxlsniwa\r\nmoSenxtfbc\r\noqssptcenz\r\nqdhmouvyas\r\n100\r\nqtMDVUXJpSEFgPsLKyRJVRbfVoYaCKJDnQDLFVngVjSPzzVyMnMyuyahMRiBJuNhKtgpVqvukUolLvYEmidvXotgQUJukYwIweUW\r\n'], 'output': ['0\r\n']}, {'input': ['10 10 1\r\nmdxafehbkr\r\nyuhenybjps\r\ntvfwmiwcoh\r\njmzrepzjvx\r\nnqyorkSnuk\r\ntSmztmwidv\r\ncmmajnlqrw\r\nfiqewpdwax\r\nuesmkdcplt\r\nlgkomdcqbo\r\n100\r\nmcEQmAvFqKYMXLHQUDeIulkmAMRkIUtbKihTFJwJYQfcAelNrZWSAwHunwZTrdHaRWokgCyLqbubOpEHuZiDVoFHjvkMSoBPyGOI\r\n'], 'output': ['39\r\n']}, {'input': ['10 10 2\r\nnhfafdwqhh\r\neyvitpcthk\r\nrpiotuoqzh\r\nnxxnhuaxee\r\nyevrtirzwf\r\nkbtSsamyel\r\nfeenjvxsmo\r\nkqpenxjmde\r\nlqsamthlwp\r\njdyyqsbtbk\r\n100\r\nUHucxPWDaKonVpXEctuqYUAQnrFEZaTYxhoacNbHIMevlbDejXjitEzyVrTfcfBHWRMdJvaTkbkqccyHjtzpTbKmRAXwlXCtFKNX\r\n'], 'output': ['29\r\n']}, {'input': ['10 10 1\r\nsufnxxpdnx\r\nvttibpllhv\r\nlvbrjmfdjx\r\ngmtexvrnfh\r\nygsqrsSwxd\r\nkxbbjxgbzs\r\nedutwocmzd\r\nfebjgknyai\r\nvcvquagvrs\r\ndrdoarhgoc\r\n100\r\nZoZJXhUWyaLgBTpgbznABKHuyFcKzJmGaMhoKkKfyOGacLwBspaKtAEdwMZJFYiZUFNDxdDIDgKSCRvsbGUOXRqalbpuEqkduYpW\r\n'], 'output': ['44\r\n']}, {'input': ['10 10 2\r\ncstcrltzsl\r\nblotmquzvj\r\nuiitiytlgx\r\nwumpfdaprd\r\ntfxohqpztn\r\nvfrpsccddo\r\nneegusrkxw\r\niijfjozqjq\r\nioegbvuhew\r\npjjpqdxvqu\r\n100\r\nkPCBONfZLkeXzWVuSgvinPENazcnRoBcUHXwRzPyvNIiDlDSeKOYmiUmjooXuzTCtIRxKDAYeTLgjsenxHoymVazMALUADQpjVjV\r\n'], 'output': ['-1\r\n']}, {'input': ['10 10 1\r\nqztnjglyrc\r\nnukswgzajl\r\nqnpbdwjvbb\r\nliiakzcrlz\r\nnolwfzzvxd\r\nmqvhiySttx\r\nqwuizSjuto\r\nqbgwiwjukx\r\nkomyvblgkc\r\ntkzlxzgsru\r\n100\r\nYUzTZDzLFkMUhjQWbwljJCRyZGFzgJcozvROiwPktRGxkMKiPyiTvhDrtusPYhMgVAOFIjAvlpzcrUvrMrMbhkpUiyAytKfYOGTF\r\n'], 'output': ['37\r\n']}, {'input': ['10 10 1\r\nmgziiihbkq\r\niobjknuogh\r\nvntwahSopu\r\nsjsxjpaqvm\r\nwqgrodizst\r\nselzugktoi\r\nvbhfzvgjfn\r\nliqlfdcjhf\r\nbpbtpmimxb\r\npksfiydpfw\r\n100\r\nwAVZXEhKTuajdCauVTIwgnfbxWuUSmtXkjHZtNVcfTsiSAPLdpdEFdTJLZRjptUcRhAmrNjKMXmuDGatAQoaIpbddnzRGHsJrhoq\r\n'], 'output': ['39\r\n']}, {'input': ['10 10 2\r\nshbqxycvfm\r\notydudkttw\r\nqhatsxsngz\r\nixvyujtyjc\r\nsbvqhnjbak\r\neggcguuuka\r\nxcydfgjzeb\r\nytpdkcdrsq\r\nefqlpywggu\r\nfcnfrhnouo\r\n100\r\nHPqtuVckdUOhsnuhnbpekWvWKUnAEaOCihpeEvmaOKOPcIZiMixGJGEuXAaOxuUNyrIesmldLEqGnvyDKPDvFkCbRebCORHmUgeV\r\n'], 'output': ['-1\r\n']}, {'input': ['1 1 50\r\nS\r\n29\r\nargjhoaiogjiSjqfhjksdvjkSvcvn\r\n'], 'output': ['-1\r\n']}, {'input': ['1 1 50\r\nS\r\n1\r\nS\r\n'], 'output': ['-1\r\n']}, {'input': ['1 1 50\r\na\r\n29\r\nargjhoaiogjiSjqfhjksdvjkSvcvn\r\n'], 'output': ['-1\r\n']}, {'input': ['1 1 50\r\nz\r\n29\r\nargjhoaiogjiSjqfhjksdvjkSvcvn\r\n'], 'output': ['-1\r\n']}, {'input': ['2 1 2\r\nS\r\nc\r\n4\r\nCSSA\r\n'], 'output': ['-1\r\n']}]


package main

import (
  "os"
  "bufio"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n, m := getI(), getI()
  mark := make([][]bool, n)
  rows := make([]string, n)
  for r := range rows {
    rows[r] = getS()
    mark[r] = make([]bool, m)
  }
  for r := range rows {
    seen := map[byte]int{}
    for c := 0; c < m; c++ {
      ch := rows[r][c]
      if seen[ch] != 0 {
        mark[r][seen[ch]-1] = true
        mark[r][c] = true
      } else {
        seen[ch] = c+1
      }
    }
  }
  for c := 0; c < m; c++ {
    seen := map[byte]int{}
    for r := range rows {
      ch := rows[r][c]
      if seen[ch] != 0 {
        mark[seen[ch]-1][c] = true
        mark[r][c] = true
      } else {
        seen[ch] = r+1
      }
    }
  }
  chars := []byte{}
  for r := range rows {
    for c := 0; c < m; c++ {
      if !mark[r][c] {
        chars = append(chars, rows[r][c])
      }
    }
  }
  writer.WriteString(fmt.Sprintf("%s\n", string(chars)))
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	n, m, s := 0, 0, []string{}
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	raw := strings.Split(scanner.Text(), " ")
	n, _ = strconv.Atoi(raw[0])
	m, _ = strconv.Atoi(raw[1])
	for i := 0; i < n; i++ {
		scanner.Scan()
		s = append(s, scanner.Text())
	}
	r := int64(1)
	for i := 0; i < m; i++ {
		byteMap := map[byte]bool{}
		for j := 0; j < n; j++ {
			byteMap[s[j][i]] = true
		}
		r = r * int64(len(byteMap)) % int64(1000000007)
	}
	fmt.Println(r)
}

[{'input': '2 3\r\nAAB\r\nBAA\r\n', 'output': ['4\r\n']}, {'input': '4 5\r\nABABA\r\nBCGDG\r\nAAAAA\r\nYABSA\r\n', 'output': ['216\r\n']}, {'input': '1 1\r\nE\r\n', 'output': ['1\r\n']}, {'input': '2 2\r\nNS\r\nPD\r\n', 'output': ['4\r\n']}, {'input': '3 4\r\nPJKD\r\nNFJX\r\nFGFK\r\n', 'output': ['81\r\n']}, {'input': '4 5\r\nSXFMY\r\nATHLM\r\nKDDQW\r\nZWGDS\r\n', 'output': ['1024\r\n']}, {'input': '20 14\r\nJNFKBBBJYZHWQE\r\nLBOKZCPFNKDBJY\r\nXKNWGHQHIOXUPF\r\nDDNRUKVUGHWMXW\r\nMTIZFNAAFEAPHX\r\nIXBQOOHEULZYHU\r\nMRCSREUEOOMUUN\r\nHJTSQWKUFYZDQU\r\nGMCMUZCOPRVEIQ\r\nXBKKGGJECOBLTH\r\nXXHTLXCNJZJUAF\r\nVLJRKXXXWMTPKZ\r\nPTYMNPTBBCWKAD\r\nQYJGOBUBHMEDYE\r\nGTKUUVVNKAHTUI\r\nZNKXYZPCYLBZFP\r\nQCBLJTRMBDWNNE\r\nTDOKJOBKEOVNLZ\r\nFKZUITYAFJOQIM\r\nUWQNSGLXEEIRWF\r\n', 'output': ['515139391\r\n']}, {'input': '5 14\r\nAQRXUQQNSKZPGC\r\nDTTKSPFGGVCLPT\r\nVLZQWWESCHDTAZ\r\nCOKOWDWDRUOMHP\r\nXDTRBIZTTCIDGS\r\n', 'output': ['124999979\r\n']}, {'input': '9 23\r\nOILBYKHRGMPENVFNHLSIUOW\r\nLPJFHTUQUINAALRDGLSQUXR\r\nLYYJJEBNZATAFQWTDZSPUNZ\r\nHSJPIQKKWWERJZIEMLCZUKI\r\nOJYIEYDGPFWRHCMISJCCUEM\r\nLMGKZVFYIVDRTIHBWPCNUTG\r\nUBGGNCITVHAIPKXCLTSAULQ\r\nOWSAWUOXQDBSXXBHTLSXUVD\r\nUGQTIZQPBGMASRQPVPSFUWK\r\n', 'output': ['454717784\r\n']}, {'input': '25 4\r\nLVKG\r\nMICU\r\nZHKW\r\nLFGG\r\nOWQO\r\nLCQG\r\nLVXU\r\nOUKB\r\nLNQX\r\nZJTO\r\nOOQX\r\nLVQP\r\nMFQB\r\nMRQV\r\nOIQH\r\nOPXX\r\nXFKU\r\nFCQB\r\nZPKH\r\nLVCH\r\nNFCU\r\nOVQW\r\nOZKU\r\nLFHX\r\nLPXO\r\n', 'output': ['5733\r\n']}, {'input': '30 10\r\nUTNTGOKZYJ\r\nQHOUHNYZVW\r\nLTVGHJRZVW\r\nMZHYHOLZYJ\r\nERYEUEPZYE\r\nUZDBFTURYJ\r\nRVSMQTIZGW\r\nWDJQHMIRYY\r\nKCORHQPZYE\r\nRRPLFOZZVY\r\nJTXMFNNNYJ\r\nMVTGGOZZVV\r\nEHAFFNUZVF\r\nLBRNWJZNYE\r\nJVMOHTPZYJ\r\nWTARFJLZVV\r\nLVJCWOURVW\r\nLCLQFJYRVV\r\nQVBVGNJRYF\r\nNTZGHOLRYE\r\nMGQKHOUPYJ\r\nRRSSBXPZYJ\r\nRYCRGTLZYJ\r\nJRDEGNKRVW\r\nRZKFGHYRVG\r\nMDJBFNIZYG\r\nMPLWHXIZYE\r\nSRZMHMURVE\r\nMTEBBMRZYJ\r\nJPJIFOLZYM\r\n', 'output': ['919913906\r\n']}, {'input': '40 7\r\nPNTVVER\r\nPAHTQDR\r\nRXMJVAS\r\nVIQNLYC\r\nILPUSVX\r\nYJOXQDJ\r\nSEFODTO\r\nOTJMREL\r\nLIQRZGD\r\nLBJJPOR\r\nRUTYHQO\r\nRIWEPBD\r\nKQUMFIB\r\nISTRRYH\r\nXBTOTGK\r\nRFQODEY\r\nHDSTZTP\r\nYCXFAGL\r\nAREGRFU\r\nLELZUYU\r\nGVABDKH\r\nFJAMMME\r\nACVULXE\r\nJHVPJAS\r\nAAQNMBX\r\nJJGUCXG\r\nOQATILQ\r\nNEOSHJM\r\nHFLWOFM\r\nICYEQHY\r\nFACGLYP\r\nPLLXJEQ\r\nDCHXYPB\r\nAGDDZJJ\r\nLSQRXTN\r\nHDQZXIY\r\nNAHDDWW\r\nQCMXRQN\r\nFDUDSZO\r\nHKBEVTW\r\n', 'output': ['206575993\r\n']}, {'input': '2 2\r\nAA\r\nBB\r\n', 'output': ['4\r\n']}, {'input': '1 10\r\nAAAAAAAAAA\r\n', 'output': ['1\r\n']}, {'input': '2 8\r\nAAAAAAAA\r\nBBBBBBBB\r\n', 'output': ['256\r\n']}, {'input': '10 10\r\nAAAAAAAAAA\r\nBBBBBBBBBB\r\nCCCCCCCCCC\r\nDDDDDDDDDD\r\nAAAAAAAAAA\r\nBBBBBBBBBB\r\nCCCCCCCCCC\r\nDDDDDDDDDD\r\nAAAAAAAAAA\r\nBBBBBBBBBB\r\n', 'output': ['1048576\r\n']}, {'input': '1 20\r\nAAAAAAAAAAAAAAAAAAAA\r\n', 'output': ['1\r\n']}, {'input': '20 1\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\n', 'output': ['7\r\n']}, {'input': '5 60\r\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\r\nDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\r\nEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\r\n', 'output': ['449874206\r\n']}, {'input': '50 4\r\nAAAA\r\nBBBB\r\nCCCC\r\nDDDD\r\nEEEE\r\nFFFF\r\nGGGG\r\nHHHH\r\nIIII\r\nJJJJ\r\nAAAA\r\nBBBB\r\nCCCC\r\nDDDD\r\nEEEE\r\nFFFF\r\nGGGG\r\nHHHH\r\nIIII\r\nJJJJ\r\nAAAA\r\nBBBB\r\nCCCC\r\nDDDD\r\nEEEE\r\nFFFF\r\nGGGG\r\nHHHH\r\nIIII\r\nJJJJ\r\nAAAA\r\nBBBB\r\nCCCC\r\nDDDD\r\nEEEE\r\nFFFF\r\nGGGG\r\nHHHH\r\nIIII\r\nJJJJ\r\nAAAA\r\nBBBB\r\nCCCC\r\nDDDD\r\nEEEE\r\nFFFF\r\nGGGG\r\nHHHH\r\nIIII\r\nJJJJ\r\n', 'output': ['10000\r\n']}, {'input': '1 100\r\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n', 'output': ['1\r\n']}, {'input': '100 1\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\n', 'output': ['1\r\n']}, {'input': '100 1\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\nA\r\nB\r\n', 'output': ['2\r\n']}, {'input': '100 1\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nH\r\nI\r\nJ\r\nK\r\nL\r\nM\r\nN\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nH\r\nI\r\nJ\r\nK\r\nL\r\nM\r\nN\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nH\r\nI\r\nJ\r\nK\r\nL\r\nM\r\nN\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nH\r\nI\r\nJ\r\nK\r\nL\r\nM\r\nN\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nH\r\nI\r\nJ\r\nK\r\nL\r\nM\r\nN\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nH\r\nI\r\nJ\r\nK\r\nL\r\nM\r\nN\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nH\r\nI\r\nJ\r\nK\r\nL\r\nM\r\nN\r\nA\r\nB\r\n', 'output': ['14\r\n']}, {'input': '100 1\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nH\r\nI\r\nJ\r\nK\r\nL\r\nM\r\nN\r\nO\r\nP\r\nQ\r\nR\r\nS\r\nT\r\nU\r\nV\r\nW\r\nX\r\nY\r\nZ\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nH\r\nI\r\nJ\r\nK\r\nL\r\nM\r\nN\r\nO\r\nP\r\nQ\r\nR\r\nS\r\nT\r\nU\r\nV\r\nW\r\nX\r\nY\r\nZ\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nH\r\nI\r\nJ\r\nK\r\nL\r\nM\r\nN\r\nO\r\nP\r\nQ\r\nR\r\nS\r\nT\r\nU\r\nV\r\nW\r\nX\r\nY\r\nZ\r\nA\r\nB\r\nC\r\nD\r\nE\r\nF\r\nG\r\nH\r\nI\r\nJ\r\nK\r\nL\r\nM\r\nN\r\nO\r\nP\r\nQ\r\nR\r\nS\r\nT\r\nU\r\nV\r\n', 'output': ['26\r\n']}]


// 43B
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var i int
	a := make([]int, 150)
	var s, l string
	in := bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanLines)
	in.Scan()
	s = in.Text()
	in.Scan()
	l = in.Text()
	for i = 0; i < len(s); i++ {
		a[s[i]]++
	}
	for i = 0; i < len(l); i++ {
		if a[l[i]] < 1 && l[i] != ' ' {
			fmt.Print("NO")
			return
		}
		a[l[i]]--
	}
	fmt.Print("YES")
	return
}


package main

import (
        "bufio"
        "fmt"
        "os"
        "strings"
)

func doSplit(n int) []int {
        res := []int{}

        var inner func(m int)
        inner = func(m int) {
                if m == 1 {
                        return
                }

                right := m / 2
                left := m - right

                if right > 1 {
                        inner(right)
                }

                if left > 1 {
                        inner(left)
                }

                res = append(res, m)
        }

        inner(n)
        return res
}

func isNSize(s string, n int) int {
        parts := doSplit(n)

        i := 0
        ls := len(s)
        for _, p := range parts {
                need_zeros := p / 2
                need_ones := p - need_zeros

                for need_zeros > 0 && need_ones > 0 && i < ls {
                        if s[i] == '0' {
                                need_zeros -= 1
                        } else {
                                need_ones -= 1
                        }
                        i += 1
                }

                if need_zeros > 0 && need_ones > 0 {
                        return 1
                }
        }

        if i != ls {
                return -1
        }

        return 0
}

func findN(log string) int {
        min := 1
        max := 1
        cmp := isNSize(log, max)
        for cmp < 0 {
                min = max
                max *= 2
                cmp = isNSize(log, max)
        }

        if cmp == 0 {
                return max
        }

        for min < max {
                m := (min + max) >> 1
                cmp = isNSize(log, m)
                if cmp == 0 {
                        return m
                }
                if cmp < 0 {
                        min = m + 1
                } else {
                        max = m
                }
        }

        return min
}

func deconstruct(s string, n int) []int {
        b := make([]int, n)
        for i := 0; i < n; i++ {
                b[i] = i
        }

        var process func(n, start, i int) int
        process = func(n, start, i int) int {
                if n == 1 {
                        return i
                }

                left := n / 2
                right := n - left

                i = process(left, start, i)
                i = process(right, start+left, i)

                k1 := start
                m := start + (n >> 1)
                k2 := m

                buf := []int{}
                for k1 < m && k2 < start+n {
                        if s[i] == '1' {
                                buf = append(buf, b[k2])
                                k2 += 1
                        } else {
                                buf = append(buf, b[k1])
                                k1 += 1
                        }
                        i += 1
                }

                for k1 < m {
                        buf = append(buf, b[k1])
                        k1 += 1
                }
                for k2 < start+n {
                        buf = append(buf, b[k2])
                        k2 += 1
                }
                for j, bufv := range buf {
                        b[start+j] = bufv
                }

                return i
        }

        process(n, 0, 0)
        result := make([]int, n)
        c := 1
        for _, i := range b {
                result[i] = c
                c += 1
        }

        return result
}

func main() {
        reader := bufio.NewReader(os.Stdin)
        log, _ := reader.ReadString('\n')
        log = strings.TrimFunc(log, func(r rune) bool {
                return r != '0' && r != '1'
        })

        n := findN(log)
        fmt.Println(n)
        res := deconstruct(log, n)
        for i, r := range res {
                if i > 0 {
                        fmt.Print(" ")
                }
                fmt.Print(r)
        }
        fmt.Println()
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var t, n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		fmt.Println((n - 1) / 2)
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	s := readString()
	k := readInt()
	m := map[rune]int{}
	for _, v := range s {
		m[v]++
	}
	if len(m) >= k {
		fmt.Println(0)
		return
	}
	cur := len(m)
	res := 0
	for _, cnt := range m {
		for i := 1; i < cnt; i++ {
			cur++
			res++
			if cur >= k {
				fmt.Println(res)
				return
			}
			if cur > 26 {
				fmt.Println("impossible")
				return
			}
		}
	}
	fmt.Println("impossible")
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

[{'input': 'yandex\r\n6\r\n', 'output': ['0\r\n']}, {'input': 'yahoo\r\n5\r\n', 'output': ['1\r\n']}, {'input': 'google\r\n7\r\n', 'output': ['impossible\r\n']}, {'input': 'a\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'z\r\n2\r\n', 'output': ['impossible\r\n']}, {'input': 'fwgfrwgkuwghfiruhewgirueguhergiqrbvgrgf\r\n26\r\n', 'output': ['14\r\n']}, {'input': 'nfevghreuoghrueighoqghbnebvnejbvnbgneluqe\r\n26\r\n', 'output': ['12\r\n']}, {'input': 'a\r\n3\r\n', 'output': ['impossible\r\n']}, {'input': 'smaxpqplaqqbxuqxalqmbmmgubbpspxhawbxsuqhhegpmmpebqmqpbbeplwaepxmsahuepuhuhwxeqmmlgqubuaxehwuwasgxpqmugbmuawuhwqlswllssueglbxepbmwgs\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'cuguccgcugcugucgggggcgcgucgucugcuuuccccuugccg\r\n4\r\n', 'output': ['1\r\n']}, {'input': 'fcfccfcfccfcfcffcffffffcfccfccfcffccccfcffffccfccfcffcfcccccffcfffcccffcfccfffffcccfccffffffccfccccf\r\n20\r\n', 'output': ['18\r\n']}, {'input': 'swmkwaruyv\r\n5\r\n', 'output': ['0\r\n']}, {'input': 'tnbqpsuhkczmejirvyfdolxwga\r\n22\r\n', 'output': ['0\r\n']}, {'input': 'abcde\r\n3\r\n', 'output': ['0\r\n']}, {'input': 'abb\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'aaaa\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'abcde\r\n2\r\n', 'output': ['0\r\n']}, {'input': 'yandex\r\n4\r\n', 'output': ['0\r\n']}, {'input': 'aaabbbccc\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'abcd\r\n2\r\n', 'output': ['0\r\n']}, {'input': 'asdfgh\r\n2\r\n', 'output': ['0\r\n']}, {'input': 'aab\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'mynameissako\r\n5\r\n', 'output': ['0\r\n']}, {'input': 'abcde\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'abcd\r\n3\r\n', 'output': ['0\r\n']}, {'input': 'abcdef\r\n2\r\n', 'output': ['0\r\n']}, {'input': 'abcdefg\r\n4\r\n', 'output': ['0\r\n']}, {'input': 'abc\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'asdafjsgljdllgjdgkl\r\n5\r\n', 'output': ['0\r\n']}, {'input': 'yaay\r\n3\r\n', 'output': ['1\r\n']}, {'input': 'yaay\r\n4\r\n', 'output': ['2\r\n']}, {'input': 'zzzzzz\r\n2\r\n', 'output': ['1\r\n']}]


// http://codeforces.com/problemset/problem/15/A
package main

import (
	"fmt"
	"bufio"
	"os"
	"sort"
)

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

type House struct {
	start, len int
}
type Houses []House

func (p Houses) Len() int {
	return len(p)
}

func (p Houses) Less(i, j int) bool {
	return p[i].start < p[j].start
}

func (p Houses) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func main () {
	var n, t int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)

	fmt.Fscanln(input, &n, &t)

	p := make(Houses, n)

	for i := 0; i < n; i++ {
		fmt.Fscan(input, &p[i].start, &p[i].len)
	}

	sort.Sort(p)
	ans := 2

	for i := 1; i < len(p); i++ {
		free := float64(p[i].start) - float64(p[i].len) / 2 - (float64(p[i - 1].start) + float64(p[i - 1].len) / 2)
		if free == float64(t) {
			ans++
		}
		if free > float64(t) {
			ans+=2
		}
	}

	fmt.Println(ans)
}


package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	n := io.NextInt()

	x, y := make([]int, n), make([]int, n)
	parent := make([]int, n)
	sz := make([]int, n)

	for i := 0; i < n; i++ {
		parent[i] = i
		sz[i] = 1
		x[i], y[i] = io.NextInt(), io.NextInt()
	}

	var find func(int) int
	find = func(a int) int {
		if parent[a] == a {
			return a
		}
		parent[a] = find(parent[a])
		return parent[a]
	}

	var unite func(int, int)
	unite = func(a, b int) {
		a = find(a)
		b = find(b)
		if a != b {
			if sz[b] > sz[a] {
				a = a ^ b
				b = a ^ b
				a = a ^ b
			}
			parent[b] = a
			sz[a] += sz[b]
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if x[i] == x[j] || y[i] == y[j] {
				unite(i, j)
			}
		}
	}

	ans := -1
	for i := 0; i < n; i++ {
		if i == find(i) {
			ans++
		}
	}

	io.Println(ans)
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, f.c[0])
	}
	return string(s)
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}


// 34A-mic
package main

import (
    "fmt"
    "math"
)

func main() {
    a := make([]int, 105)
    var n, j, k int
    b := 10000
    c := 0
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    a[n] = a[0]
    for i := 0; i < n; i++ {
        c = int(math.Abs(float64(a[i]) - float64(a[i+1])))
        if c < b {
            b = c
            j = i + 1
            k = j + 1
            if n+1 == k {
                k = 1
            }
        }
    }
    fmt.Print(j)
    fmt.Print(" ")
    fmt.Print(k)
    fmt.Println()
}