import sys
readline=sys.stdin.readline

N=int(readline())
dp=[0]*(1<<24)
dp[-1]=N
for _ in range(N):
    bit=(1<<24)-1
    for a in readline().rstrip():
        a=ord(a)-97
        if bit&1<<a:
            bit^=1<<a
    dp[bit]-=1
for i in range(24):
    for bit in range((1<<24)-1,-1,-1):
        if not bit&1<<i:
            dp[bit]+=dp[bit^1<<i]
ans=0
for x in dp:
    ans^=x**2
print(ans)


from bisect import bisect_left as bl
I=10000000
n=int(input())+1
c=[0]*n
for i,x in enumerate(map(int,input().split())): c[x]=i
d = [n-c[int(x)] for x in input().split()]
c=[I]*n
for i in d: c[bl(c,i)]=i
print( c.index(I))


P = 998244353
N, M = map(int, raw_input().split())
A = [int(a) for a in raw_input().split()]
B = [int(a) for a in raw_input().split()]
li = sum([A[i]*B[i] for i in range(N)])
di = sum([(A[i]^1)*B[i] for i in range(N)])
X = [1]
SU = li+di
PO = [0] * (5*M+10)
for i in range(-M-5, 2*M+5):
    PO[i] = pow((SU+i)%P, P-2, P)
def calc(L):
    su = sum(L)
    pl = 0
    pd = 0
    RE = []
    for i in range(len(L)):
        a = li + i
        b = di - (len(L) - 1 - i)
        pd = b * L[i] * PO[a+b-SU]
        RE.append((pl+pd)%P)
        pl = a * L[i] * PO[a+b-SU]
    RE.append(pl%P)
    return RE
for i in range(M):
    X = calc(X)
ne = 0
po = 0
for i in range(M+1):
    po = (po + X[i] * (li + i)) % P
    ne = (ne + X[i] * (di - M + i)) % P
invli = pow(li, P-2, P)
invdi = pow(di, P-2, P)
for i in range(N):
    print(po * B[i] * invli % P if A[i] else ne * B[i] * invdi % P)


n=input()
I=range(n)
a=map(int,raw_input().split())
l=int(max(a[i]/(i+1.) for i in I)*(n+1)+1e-9)
h=int(min((a[i]+1.)/(i+1) for i in I)*(n+1)-1e-9)
if l<h:
  print 'not unique'
else:
  print 'unique'
  print l


import itertools

N,max,reg = map(int,raw_input().split())
pow = [0]*N
dmg = [0]*N
for i in range(N):
	pow[i],dmg[i] = map(int,raw_input().split())

history = []
used = [False]*N

HP = max
for t in itertools.count():
	prev = HP

	for i in range(N):
		if used[i]:
			HP -= dmg[i]
	HP = min(HP+reg,max)

	if HP<=0:
		print "YES"
		print t, len(history)
		for s in history:
			print s
		break

	s = -1
	for i in range(N):
		if ( not used[i] and
		     100*HP<=max*pow[i] and
		     ( s==-1 or dmg[i]>dmg[s] ) ):
			s = i
	if s!=-1:
		used[s] = True
		history += ["%d %d"%(t,s+1)]

	if HP==prev and s==-1:
		print "NO"
		break


import sys

def genPrimes(bound):
	isPrime = [True] * max(bound + 1, 2)
	isPrime[0] = isPrime[1] = False
	for i in range(4, len(isPrime), 2):
		isPrime[i] = False
	for i in range(3, len(isPrime), 2):
		if isPrime[i]:
			for j in range(i * i, len(isPrime), 2 * i):
				isPrime[j] = False
	return [x for x in range(len(isPrime)) if isPrime[x]]

def div(f1, f2):
	return [f1[i] - f2[i] for i in range(len(f1))]

def fact(primes, n):
	res = [0] * len(primes)
	for i in range(len(primes)):
		q = primes[i]
		while n / q > 0:
			res[i] += n / q
			q *= primes[i]
	return res

def c(primes, n, k):
	return div(div(fact(primes, n), fact(primes, k)), fact(primes, n - k))

#cin = open("input.txt", "rt")
cin = sys.stdin
n, m, h = [int(x) for x in cin.readline().split()]
a = [int(x) for x in cin.readline().split()]

h -= 1
n -= 1
a[h] -= 1
a[h], a[-1] = a[-1], a[h]
left, right = sum(a[:-1]), a[-1]

if left + right < n:
	print -1
	sys.exit(0)
if n > left:
	print 1
	sys.exit(0)

primes = genPrimes(left + right)

num = c(primes, left, n)
den = c(primes, left + right, n)

for i in range(len(primes)):
	v = min(num[i], den[i])
	num[i] -= v
	den[i] -= v

ans = 1.0
for i in range(len(primes)):
	for _ in range(num[i]):
		ans *= primes[i]
	for _ in range(den[i]):
		ans /= primes[i]
print "%.6f" % (1.0 - ans)


#include<stdio.h>
#include<stdlib.h>

typedef struct player{
	int skill;
	int order;
} player_t;

player_t a[100001];
int n;

int compare(const void * a, const void * b){
	return ((player_t*)a)->skill-((player_t*)b)->skill;
}
int main(){
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&(a[i].skill));
		a[i].order = i+1;
	}
	qsort(a,n,sizeof(player_t),compare);
	if(n%2==0) printf("%d\n",n/2);
	else printf("%d\n",n/2+1);
	i=0;
	while(i<n){
		printf("%d ",a[i].order);
		i+=2;
	}
	printf("\n");
	printf("%d\n",n/2);
	i=1;
	while(i<n){
		printf("%d ",a[i].order);
		i+=2;
	}
	printf("\n");
	return 0;
}


[{'input': 'abdrakadabra\r\nabrakadabra\r\n', 'output': ['1\r\n3 ']}, {'input': 'aa\r\na\r\n', 'output': ['2\r\n1 2 ']}, {'input': 'competition\r\ncodeforces\r\n', 'output': ['0\r\n']}, {'input': 'ab\r\na\r\n', 'output': ['1\r\n2 ']}, {'input': 'bb\r\nb\r\n', 'output': ['2\r\n1 2 ']}, {'input': 'aab\r\nab\r\n', 'output': ['2\r\n1 2 ']}, {'input': 'aabb\r\nabb\r\n', 'output': ['2\r\n1 2 ']}, {'input': 'babaacaacaa\r\nbbaacaacaa\r\n', 'output': ['1\r\n2 ']}, {'input': 'bccaabbcccc\r\nbccaabcccc\r\n', 'output': ['2\r\n6 7 ']}, {'input': 'ababcaabaaa\r\nabacaabaaa\r\n', 'output': ['1\r\n4 ']}, {'input': 'cccacaccacb\r\ncccacaccac\r\n', 'output': ['1\r\n11 ']}, {'input': 'aaaaaaaaaaa\r\naaaaaaaaaa\r\n', 'output': ['11\r\n1 2 3 4 5 6 7 8 9 10 11 ']}, {'input': 'lcaaxcbcjca\r\nccaaacccca\r\n', 'output': ['0\r\n']}, {'input': 'babbbtaamba\r\nbabbbaabba\r\n', 'output': ['0\r\n']}, {'input': 'xdfxmcnzpch\r\nazvotghvtk\r\n', 'output': ['0\r\n']}, {'input': 'ki\r\nb\r\n', 'output': ['0\r\n']}, {'input': 'vct\r\nie\r\n', 'output': ['0\r\n']}, {'input': 'feee\r\nsnl\r\n', 'output': ['0\r\n']}, {'input': 'cbxxxxzvks\r\ncbxxxzvks\r\n', 'output': ['4\r\n3 4 5 6 ']}, {'input': 'qybldcgfhdhhhhhhhhhhopqkhuczzytzluiahwbqjltgafvvoecititchjwdoljiehubngmtjckqymldhoncgtqhxnqvoagnrmur\r\nqybldcgfhdhhhhhhhhhopqkhuczzytzluiahwbqjltgafvvoecititchjwdoljiehubngmtjckqymldhoncgtqhxnqvoagnrmur\r\n', 'output': ['10\r\n11 12 13 14 15 16 17 18 19 20 ']}]


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>

#define PI 3.141592653589793
#define max(a,b) (a < b) ? (b) : (a)
#define min(a,b) (a > b) ? (b) : (a)
#define FOR(i,a,b) for(i = a ; i <= b ; i++)
#define ROF(i,a,b) for(i = a ; i >= b ; i--)
#define RAD(x) ((x)*PI)/180
#define y1 y_1
#define endl printf("\n")
#define MAX 1005

int n, m, i, j, k, x, y, sum, parca, mat[MAX][MAX], h1[MAX], h2[MAX], h[MAX];

int dfs (int);

int main () {
	scanf("%d %d", &n, &m);
	FOR(i, 1, m){
		scanf("%d %d", &x, &y);
		mat[x][y] = mat[y][x] = 1;
	}
	FOR(i, 1, n)
		if(!h[i]){
			dfs(i);
			parca++;
		}
	FOR(i, 1, n){
		FOR(j, 1, n){
			if(mat[i][j])
				h1[i]++;
			if(mat[j][i])
				h2[j]++;
		}
	}
	FOR(k, 1, 10005)
		FOR(j, 1, n)
		if(h1[j] == 1 && h2[j] == 1)
			FOR(i, 1, n)
				if(mat[i][j]){
					h1[j] = 0;
					h2[j] = 0;
					h1[i]--;
					h2[i]--;
					mat[i][j] = 0;
					mat[j][i] = 0;
				}
	FOR(i, 1, n){
		if(h1[i] > 2 || h2[i] > 2){
			printf("NO");
			return 0;
		}
	}
	FOR(i, 1, n)
		sum += h1[i] + h2[i];
	if(sum && parca == 1)
		printf("FHTAGN!");
	else
		printf("NO");
	return 0;
}

int dfs (int x){
	int i;
	if(h[x])
		return;
	h[x] = 1;
	FOR(i, 1, n)
		if(mat[i][x])
			dfs(i);
}


#include <stdio.h>
main()
{
    int n,i,a,b,sum;
    sum=0;
    scanf("%d",&n);
    int c[n];
    for(i=0;i<n-1;i++)
    {
        scanf("%d",&c[i]);
    }
    scanf("%d %d",&a,&b);
    for(i=a;i<b;i++)
    {
        sum=sum+c[i-1];
    }
    printf("%d",sum);
}


#include <stdio.h>

int f[1001];

int main()
{

    int n;
    scanf("%d", &n);

    int pos=1;
    for(int i=1;i<n;i++)
    {
        pos=(pos+i)%n;
        if(pos==0) pos=n;
        printf("%d ", pos);
    }

    return 0;
}


/* Problem: 722A - Broken Clock */
/* Solver: Gusztav Szmolik */

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main ()
    {
    unsigned short tf;
    unsigned char tm[7];
    unsigned short h;
    unsigned short m;

    if (scanf("%hu",&tf) != 1)
        return -1;
    if (tf != 12 && tf != 24)
        return -1;
    if (scanf("%6s",tm) != 1)
        return -1;
    if (strlen(tm) != 5)
        return -1;
    if (!isdigit(tm[0]) || !isdigit(tm[1]) || !isdigit(tm[3]) || !isdigit(tm[4]))
        return -1;
    if (tm[2] != ':')
        return -1;
    h = 10*(tm[0]-'0')+tm[1]-'0';
    m = 10*(tm[3]-'0')+tm[4]-'0';
    if (tf == 12 && !h)
        printf ("01:");
    else if (tf == 12 && h > 12)
        {
        if (tm[1] == '0')
            printf ("10:");
        else
            printf ("0%c:",tm[1]);
        }
    else if (tf == 24 && h > 23)
        printf ("0%c:",tm[1]);
    else
        printf ("%c%c:",tm[0],tm[1]);
    if (m > 59)
        printf ("0%c\n",tm[4]);
    else
        printf ("%c%c\n",tm[3],tm[4]);
    return 0;
    }


#include<stdio.h>
long long d[20];
void compute()
{
    d[0]=9;
    d[1]=18;
    long long s=10,i;
    for(i=2;i<20;++i)
    {
        d[i]=9*s+d[i-1];
        s*=10;
    }
}
long long find(long long x)
{
    if(x<10)
        return x;
    long long ans=0;
    ans=x/10+9;
    return ans;
}
int main()
{
    long long l,r,x,ans=0,rem;
    scanf("%lld%lld",&l,&r);
    x=r;
    rem=x%10;
    while(x>=10)
        x/=10;
    if(x>rem)
        ans-=1;
    x=l-1;
    rem=(l-1)%10;
    while(x>=10)
        x/=10;
    if(x>rem)
        ans+=1;
    compute();
    ans-=find(l-1);
    ans+=find(r);
    printf("%lld",ans);
    return 0;
}


[{'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']}]


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define mod 1000000007
typedef long long int li;
int hash[128];
char strings[101][101];
int main()
{
	//freopen("program.txt","r",stdin);
	int n,m;
	scanf("%d %d",&n,&m);
	int i,j,k;
	for(i=0;i<n;i++)
	{
		scanf("%s",strings[i]);
		//printf("%s\n",strings[i]);
	}
	li ans=1;
	for(i=0;i<m;i++)
	{
		memset(hash,0,sizeof(hash));
		int count=0;
		for(j=0;j<n;j++)
		{
			if(hash[strings[j][i]]==0)
			 count++;
			hash[strings[j][i]]++;
		}
		ans=(1ll*ans*count)%mod;
	}
	printf("%I64d\n",ans);
	return 0;
}

[{'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']}]


#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
    char h[200];
    char t[200];
    int i,j,c=0;
    gets(h);
    gets(t);
    for(i=0;i<strlen(t);i++)
    {
        if(t[i]!=' ')
        {
           for(j=0;j<strlen(h);j++)
           {
            if(h[j]==t[i])
            {
                h[j]=-1;
                break;

            }
            else
            {
                if(j==strlen(h)-1)
                {
                    c=1;
                    break;
                }

            }

           }

        }
        if(c==1)
        {
         printf("NO");
         break;
        }

    }
    if(c==0)
    {

        printf("YES");
    }

    return(0);
}

[{'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']}]


#include<stdio.h>
#include <string.h>

int main(){
    char sequance[100003];
   scanf("%s", sequance);
   char a[103];
   char b[103];
   int n1=0;
   int n2=0;
   int n3=0;
   int n4=0;
   scanf("%s", a);
   scanf("%s", b);
   int current=0;
   int current2=0;
   int lenseq=strlen(sequance);
   int lena=strlen(a);
   int lenb=strlen(b);
//   if (sequance[1000]=='a'){

//       printf("%d lenseq\n", lenseq);
//       printf("%d lena\n", lena);
//       printf("%d lenb\n", lenb);
//   }
   for (int j=0;j<=lenseq-lena;j++){
       if (sequance[j]==a[0]) {
           n1=1;
           for (int i=1;i<lena;i++){
               if(sequance[j+i]==a[i]){
                   n1++;
               } else break;
           }
       }
       if (n1==lena) {current= j+lena;break;}
   }

   for (int j=current;j<=lenseq-lenb;j++){
       if (sequance[j]==b[0]) {
           n2=1;
           for (int i=1;i<lenb;i++){
               if(sequance[j+i]==b[i]){
                   n2++;
               } else break;
           }
       }
        if (n2==lenb) {break;}
   }

   for (int j=lenseq-1;j>=lena-1; j--){
       if (sequance[j]==a[0]) {
          n3=1;
           for (int i=1;i<lena;i++){

               if(sequance[j-i]==a[i]){
                   n3++;
               } else break;
           }
       }
       if (n3==lena) {current2=j-lena;break;}
   }

   for (int j=current2;j>=0; j--){
       if (sequance[j]==b[0]) {
           n4=1;
           for (int i=1;i<lenb;i++){
               if(sequance[j-i]==b[i]){
                   n4 ++;

               } else break;
           }
       }
       if (n4==lenb) {break;}
   }

   if (((n1!=lena || n2!=lenb) && (n3!=lena ||n4!=lenb ) )|| lena+lenb>lenseq) {
       printf("fantasy");
   }
   else if ( (n1==lena && n2==lenb) && (n3!=lena || n4!=lenb )) {
        printf("forward");
   }
   else if ( (n1!=lena || n2!=lenb) && (n3==lena && n4==lenb )) {
        printf("backward");
   }
   else if ( (n1==lena || n2==lenb) && (n3==lena && n4==lenb )) {
        printf("both");
   }
}

[{'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']}]


#include <stdio.h>

int cloth[101][101], price[101];

int main()

{

int n, m, i, j, k, x, y, cost, min;

while(scanf("%d%d", &n, &m)!=EOF)

{

cost=0; min=0xffffff;

for(i=1; i<=n; i++)

scanf("%d", &price[i]);

for(i=0; i<m; i++)

{

scanf("%d%d", &x, &y);

cloth[x][y]=cloth[y][x]=1;

}

for(i=1; i<=n; i++)

{

for(j=1; j<=n; j++)

{

if(i!=j)

{

for(k=1; k<=n; k++)

{

if(i!=k&&k!=j)

{

if(cloth[i][j]==1&&cloth[j][k]==1&&cloth[k][i]==1)

{

cost=price[i]+price[j]+price[k];

if(cost<min)

min=cost;

}

}

}

}

}

}

if(min==0xffffff)

printf("-1\n");

else

printf("%d\n", min);

}

return 0;
}


#include<stdio.h>
#include<stdlib.h>

int main()
{
    int n,i,j,min=10000,count1,count2;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0,j=1;i<n;i++,j++){
        if(i+1==n){
            j=0;
        }
        if(min>abs(a[i]-a[j])){
            min=abs(a[i]-a[j]);
            count1=i;
            count2=j;
        }
    }

    printf("%d %d\n",count1+1,count2+1);
    return 0;
}


#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
	int i, j, l, n, m;
	long long sum, maxsum, max;
	static int a[5000];
	static long long sum0[50], sum1[50], sum2[50], mm[50], *dp[3], msum[50];

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%d", &l);
		mm[i] = INT_MIN;
		sum1[i] = 0;
		for (j = 0; j < l; j++) {
			scanf("%d", &a[j]);
			if (mm[i] < a[j])
				mm[i] = a[j];
			sum1[i] += a[j];
		}
		sum0[i] = sum2[i] = 0;
		sum = 0;
		for (j = 0; j < l; j++) {
			sum += a[j];
			if (sum0[i] < sum)
				sum0[i] = sum;
		}
		sum = 0;
		for (j = l - 1; j >= 0; j--) {
			sum += a[j];
			if (sum2[i] < sum)
				sum2[i] = sum;
		}
		sum = 0;
		maxsum = 0;
		for (j = 0; j < l; j++) {
			sum += a[j];
			if (sum < 0)
				sum = 0;
			if (maxsum < sum)
				maxsum = sum;
		}
		msum[i] = maxsum;
	}
	for (i = 0; i < 3; i++)
		dp[i] = malloc(sizeof(*dp[i]) * m);
	max = INT_MIN;
	maxsum = 0;
	for (i = 0; i < m; i++) {
		int k;

		scanf("%d", &k);
		k--;
		if (i == 0) {
			dp[0][i] = sum2[k];
			dp[1][i] = sum1[k];
			dp[2][i] = sum0[k];
		} else {
			dp[0][i] = sum2[k];
			dp[1][i] = (dp[0][i - 1] > dp[1][i - 1]
					? dp[0][i - 1] : dp[1][i - 1]) + sum1[k];
			dp[2][i] = (dp[0][i - 1] > dp[1][i - 1]
					? dp[0][i - 1] : dp[1][i - 1]) + sum0[k];
		}
		if (maxsum < dp[0][i])
			maxsum = dp[0][i];
		if (maxsum < dp[1][i])
			maxsum = dp[1][i];
		if (maxsum < dp[2][i])
			maxsum = dp[2][i];
		if (maxsum < msum[k])
			maxsum = msum[k];
		if (max < mm[k])
			max = mm[k];
	}
	printf("%lld\n", maxsum == 0 ? max : maxsum);
	return 0;
}


#include <stdio.h>

int n,m;
char input[11][36] = {{'\0'},{'\0'}};
int errors[11] = {0};
int poss = 0;
char arr[36] = {0};
int visited[11] = {0};
int check()
{
    int counter =0;
    for (int i=0;i<m;i++)
    {
        int counter=0;
        for (int j =0;j<n;j++)
        {
            if (input[i][j] != arr[j])
                counter++;
        }
        if (counter != errors[i])
            return 0;
    }
    return 1;
}
char change(char num)
{
    if (num == '0')
        return '1';
    else
        return '0';
}

void solve (int place,int var)
{
    if (var == 0)
    {
        if (check())
            poss++;
            return;
    }
    if (place == n)
        return;
    arr[place] =change(arr[place]);
    solve(place+1,var-1);
    arr[place] = change(arr[place]);
    solve (place+1,var);
}

int main()
{
    int max=0,max_index = 0;
    scanf("%i %i",&n,&m);
    for (int i =0;i<m;i++)
    {
        scanf("%s %i",&input[i],&errors[i]);
        if (errors[i] > max)
        {
            max = errors[i];
            max_index = i;
        }
    }
//    for (int i =0;i<m;i++)
//    {
//        strcpy(arr,input[i]);
//        solve(0,errors[i]);
//    }
//    printf("%i",poss/m);
    strcpy(arr,input[max_index]);
    solve(0,errors[max_index]);
    printf("%i",poss);
}


#include<stdio.h>
#include<string.h>
int n,m,q,ip1[200][200],procinfo[40000][10],status[200][200],ip2[10][2],glob[10],nm;
char ch[201],inch[1000001];

void fill_glob(int si,int sj,int ei,int ej){

int i,dx,dy;
for(i=0;i<10;i++)
    glob[i]=-1;

while(!(si==ei && sj == ej)){
if(glob[ip1[si][sj]]==-1)
    glob[ip1[si][sj]]=si*m+sj;

dx=ip2[ip1[si][sj]][0];
dy=ip2[ip1[si][sj]][1];

si=si+dx;
sj=sj+dy;

}

if(glob[ip1[si][sj]]==-1)
    glob[ip1[si][sj]]=si*m+sj;

//test
/*printf("%d %d %d %d\n",si,sj,ei,ej);
for(i=0;i<10;i++)
    printf("%d ",glob[i]);
printf("\n");*/

}

void process_indx(int i,int j){

status[i][j]=-2;
int ni,nj,dx,dy,eq,l,neq;
eq=i*m+j;
dx=ip2[ip1[i][j]][0];
dy=ip2[ip1[i][j]][1];
ni=i+dx;
nj=j+dy;
neq=ni*m+nj;

if(ni<0 || ni>n-1 || nj <0 || nj >m-1){
for(l=0;l<10;l++)
    procinfo[eq][l]=-1;
    procinfo[eq][ip1[i][j]]=eq;
status[i][j]=0;
return;
}

if(status[ni][nj]==-2){

fill_glob(ni,nj,i,j);
for(l=0;l<10;l++)
    procinfo[eq][l]=glob[l];
status[i][j]=0;
return;
}

if(status[ni][nj]==-1){

    process_indx(ni,nj);

}

    for(l=0;l<10;l++)
    procinfo[eq][l]=procinfo[neq][l];
    procinfo[eq][ip1[ni][nj]]=neq;
    status[i][j]=0;
    return;

}

void read_input(){
int i,j;
scanf("%d %d %d",&n,&m,&q);
for(i=0;i<n;i++){
   scanf("%s",ch);
    for(j=0;j<m;j++){
        ip1[i][j]=ch[j]-'0';
        status[i][j]=-1;
    }
}
for(i=0;i<10;i++)
    scanf("%d %d",&ip2[i][0],&ip2[i][1]);

nm=n*m;
}

void process_info(){
int i,j;
for(i=0;i<n;i++)
    for(j=0;j<m;j++)
     {
          if(status[i][j]==0)
            continue;
          process_indx(i,j);
     }

//test

/*for(i=0;i<n*m;i++){
    for(j=0;j<10;j++)
    printf("%d ",procinfo[i][j]);
printf("\n");

}*/

}

int main(){
int i,len,j,x,y,k,curindx;
read_input();
process_info();

for(i=0;i<q;i++){
scanf("%s",inch);
len=strlen(inch);
for(j=0;j<n;j++)
    for(k=0;k<m;k++)
       status[j][k]=-1;
for(j=0;j<nm;j++){
    x=j/m;
    y=j-x*m;
    if(ip1[x][y]!=inch[0]-'0')
        continue;
    if(status[x][y]!=-1)
        continue;
    status[x][y]=0;
    curindx=j;
    for(k=1;k<len;k++){
       curindx=procinfo[curindx][inch[k]-'0'];
       if(curindx==-1)
         break;
       x=curindx/m;
       y=curindx-x*m;
       if(status[x][y]!=-1 && status[x][y] >=k)
        break;
       status[x][y]=k;
   }

    if(k==len)
        break;

}

if(j<nm)
    printf("YES\n");
else
    printf("NO\n");

}
return 0;

}


#include <stdio.h>
#include <stdlib.h>

#define X	1000000
#define Q	100000

long long cross2(long long x1, long long y1, long long x2, long long y2) {
	return x1 * y2 - x2 * y1;
}

struct P {
	int x, y;
} *pl, *pr;

typedef struct P *T[(X + X + 1) * 4];

long long cross(struct P *o, struct P *p, struct P *q) {
	return cross2(p->x - o->x, p->y - o->y, q->x - o->x, q->y - o->y);
}

struct P *min(struct P *p, struct P *q) {
	return p != NULL && q != NULL ? (p->x < q->x ? p : q) : (p == NULL ? q : p);
}

struct P *max(struct P *p, struct P *q) {
	return p != NULL && q != NULL ? (p->x > q->x ? p : q) : (p == NULL ? q : p);
}

void update(T tl, T tr, int k, int l, int r, int x, struct P *p) {
	int m;

	if (r - l == 1) {
		tl[k] = tr[k] = p;
		return;
	}
	m = (l + r) / 2;
	if (x < m)
		update(tl, tr, k * 2 + 1, l, m, x, p);
	else
		update(tl, tr, k * 2 + 2, m, r, x, p);
	tr[k] = min(tr[k * 2 + 1], tr[k * 2 + 2]);
	tl[k] = max(tl[k * 2 + 1], tl[k * 2 + 2]);
}

void query(T tl, T tr, int k, int l, int r, int x) {
	int m;

	if (r - l == 1) {
		pl = max(pl, tl[k]);
		pr = min(pr, tr[k]);
		return;
	}
	m = (l + r) / 2;
	if (x < m) {
		pr = min(pr, tr[k * 2 + 2]);
		query(tl, tr, k * 2 + 1, l, m, x);
	} else {
		pl = max(pl, tl[k * 2 + 1]);
		query(tl, tr, k * 2 + 2, m, r, x);
	}
}

int query_(T tl_up, T tr_up, T tl_dn, T tr_dn, struct P *p, int insert) {
	struct P *q, *pl_, *pr_;
	int inside = 1;

	pl = pr = NULL;
	query(tl_up, tr_up, 0, 0, X + X + 1, p->x);
	pl_ = pl, pr_ = pr;
	if ((pl == pr
				&& (pl == NULL || pl->y < p->y))
			|| (pl != pr
				&& (pl == NULL || pr == NULL || cross(pl, p, pr) < 0))) {
		if (insert) {
			for (q = pl_; q && q->x > 0; q = pl) {
				pl = pr = NULL;
				query(tl_up, tr_up, 0, 0, X + X + 1, q->x - 1);
				if (!pl || cross(pl, q, p) < 0)
					break;
				update(tl_up, tr_up, 0, 0, X + X + 1, q->x, NULL);
			}
			for (q = pr_; q && q->x < X + X; q = pr) {
				pl = pr = NULL;
				query(tl_up, tr_up, 0, 0, X + X + 1, q->x + 1);
				if (!pr || cross(p, q, pr) < 0)
					break;
				update(tl_up, tr_up, 0, 0, X + X + 1, q->x, NULL);
			}
			update(tl_up, tr_up, 0, 0, X + X + 1, p->x, p);
		}
		inside = 0;
	}
	pl = pr = NULL;
	query(tl_dn, tr_dn, 0, 0, X + X + 1, p->x);
	pl_ = pl, pr_ = pr;
	if ((pl == pr
				&& (pl == NULL || pl->y > p->y))
			|| (pl != pr
				&& (pl == NULL || pr == NULL || cross(pl, p, pr) > 0))) {
		if (insert) {
			for (q = pl_; q && q->x > 0; q = pl) {
				pl = pr = NULL;
				query(tl_dn, tr_dn, 0, 0, X + X + 1, q->x - 1);
				if (!pl || cross(pl, q, p) > 0)
					break;
				update(tl_dn, tr_dn, 0, 0, X + X + 1, q->x, NULL);
			}
			for (q = pr_; q && q->x < X + X; q = pr) {
				pl = pr = NULL;
				query(tl_dn, tr_dn, 0, 0, X + X + 1, q->x + 1);
				if (!pr || cross(p, q, pr) > 0)
					break;
				update(tl_dn, tr_dn, 0, 0, X + X + 1, q->x, NULL);
			}
			update(tl_dn, tr_dn, 0, 0, X + X + 1, p->x, p);
		}
		inside = 0;
	}
	return inside;
}

int main() {
	static T tl_up, tr_up, tl_dn, tr_dn;
	int q;

	scanf("%d", &q);
	while (q-- > 0) {
		struct P *p = malloc(sizeof *p);
		int t;

		scanf("%d%d%d", &t, &p->x, &p->y);
		p->x += X;
		if (t == 1)
			query_(tl_up, tr_up, tl_dn, tr_dn, p, 1);
		else
			printf(query_(tl_up, tr_up, tl_dn, tr_dn, p, 0) ? "YES\n" : "NO\n");
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long LL;

int comp(const void * a, const void * b){
	return *((int*)a)-*((int*)b);
}

int a[200], n, k;
LL dp[2][201][1001];
const LL mod=1000000007;

LL get(int i, int num, int s){
	if(s>k || num<0) return 0;
	return dp[i&1][num][s];
}

int main(){
	int i, j, l, add;
	scanf("%d %d", &n, &k);
	for(i=0;i<n;++i) scanf("%d", a+i);
	for(i=0;i<=k;++i) dp[n&1][0][i]=1;
	for(i=1;i<=n;++i) for(j=0;j<=k;++j) dp[n&1][i][j]=0;
	qsort(a, n, sizeof(int), comp);
	for(i=n-1;i>0;--i){
		for(j=0;j<=n;++j){
			add=j*(a[i]-a[i-1]);
			for(l=0;l<=k;++l){
				dp[i&1][j][l]=(get(i+1, j+1, l+add)+j*get(i+1, j-1, l+add)+
						(j+1)*get(i+1, j, l+add))%mod;
			}
		}
	}
	printf("%I64d\n", (get(1, 1, 0)+get(1, 0, 0))%mod);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAXN 100055
#define MAXM 15

struct node
{
	char s[MAXM];
	int len;
};

int main ()
{
	static char s[MAXN];
	memset(s,0,sizeof(s));
	scanf("%s\n",s);
	int N = strlen(s);
	int M;
	scanf("%d\n",&M);
	static struct node data[MAXM];
	int i;
	for (i = 0; i < M; i++)
	{
		scanf("%s\n",data[i].s);
		data[i].len = strlen(data[i].s);
	}
	int res = 0;
	int resw = 0;
	int min = N;
	int j, k, temp;
	char flag;
	for (i = N-1; i >= 0; i--)
	{
		for (j = 0; j < M; j++)
		{
			flag = 1;
			for (k = 0; k < data[j].len; k++)
			{
				if (s[i+k] != data[j].s[k])
				{
					flag = 0;
					break;
				}
			}
			if (flag)
			{
				temp = i + data[j].len - 1;
				if (temp < min) min = temp;
			}
		}
		temp = min - i;
		if (temp > res)
		{
			res = temp;
			resw = i;
		}
	}
	printf("%d %d\n",res,resw);
	return 0;
}

[{'input': 'Go_straight_along_this_street\r\n5\r\nstr\r\nlong\r\ntree\r\nbiginteger\r\nellipse\r\n', 'output': ['12 4\r\n']}, {'input': 'IhaveNoIdea\r\n9\r\nI\r\nh\r\na\r\nv\r\ne\r\nN\r\no\r\nI\r\nd\r\n', 'output': ['0 0\r\n']}, {'input': 'unagioisii\r\n2\r\nioi\r\nunagi\r\n', 'output': ['5 5\r\n']}, {'input': 'abcabcabcabc\r\n3\r\nabcabca\r\nbcab\r\ncabc\r\n', 'output': ['4 6\r\n']}, {'input': 'ThankYouForParticipatingRound71\r\n6\r\nForP\r\noun\r\nnkYouForP\r\nTha\r\nouForP\r\nound7\r\n', 'output': ['18 9\r\n']}, {'input': 'WishYourSolutionPassesFinalTests\r\n10\r\nrSoluti\r\ninal\r\nolutionPas\r\nassesFin\r\nourSo\r\nonP\r\nWishYourSo\r\nsFinalTes\r\nhYourSolut\r\nonPas\r\n', 'output': ['9 15\r\n']}, {'input': '9\r\n1\r\n9\r\n', 'output': ['0 0\r\n']}, {'input': 'Z\r\n1\r\na\r\n', 'output': ['1 0\r\n']}, {'input': '12abcdefghijklmnop\r\n10\r\nabcd\r\nabc\r\nab\r\na\r\nklmn\r\nlmn\r\nmn\r\nn\r\nop\r\n12\r\n', 'output': ['12 3\r\n']}, {'input': '12abcdefghijklmnop\r\n10\r\na\r\nop\r\nab\r\nabc\r\nabcd\r\nn\r\nmn\r\n12\r\nlmn\r\nklmn\r\n', 'output': ['12 3\r\n']}, {'input': '12abcdefghijklmnop\r\n10\r\nlmn\r\nabc\r\na\r\nklmn\r\nn\r\nabcd\r\nop\r\nmn\r\nab\r\n12\r\n', 'output': ['12 3\r\n']}, {'input': 'x5x5\r\n10\r\nx5\r\nx5x\r\nx5x5\r\nx5\r\nx5\r\nQyBa0yZO_c\r\n_troGKxtGQ\r\nRItOLVC3ok\r\niD_57rFYR1\r\nvZhgXwTnE4\r\n', 'output': ['2 1\r\n']}, {'input': 'aaaay\r\n10\r\naa\r\naa\r\naaa\r\nay\r\naaay\r\ndltfBoU4nF\r\nYhImrXw62Y\r\nwswb4v7CRb\r\npjxxEE3S26\r\nwxDxW1MRaI\r\n', 'output': ['1 4\r\n']}, {'input': 'iiiiii\r\n10\r\nii\r\niiii\r\niiiii\r\niii\r\niiii\r\n5avjcwIsDh\r\nGgiVQ9ylRz\r\newWmNAJAL9\r\nk83baq5H2U\r\nXRX3fJ4dH8\r\n', 'output': ['1 5\r\n']}, {'input': 'ffBBfBB\r\n10\r\nBBfB\r\nffBBfB\r\nffBBf\r\nffBBf\r\nBfB\r\n1ehoxM6CU8\r\ntvB4q05iuU\r\nEYGkY6VxQO\r\nbKbE2ajjBW\r\nhqTKbQUZds\r\n', 'output': ['4 1\r\n']}, {'input': 'aaUUUUaa\r\n10\r\naUUU\r\naaU\r\naUU\r\nUUUU\r\nUU\r\neV1R6e2tCQ\r\nmwseAsylFZ\r\njkfXnCVagR\r\nRGPm9O09J8\r\nVBRpGUFrDB\r\n', 'output': ['3 5\r\n']}, {'input': '1111e1e1e\r\n10\r\n11\r\n1111e\r\n1111\r\ne1e1e\r\n1e1\r\npuCrQxcVPh\r\nfnbEroh3w4\r\nyie11ihNIi\r\n2_23hx3yX9\r\noPKXwByQLT\r\n', 'output': ['3 6\r\n']}, {'input': 'aMaMaMMaaM\r\n10\r\nMMaaM\r\nMMaaM\r\naa\r\naMaMMaa\r\nMaMa\r\nWoEVf7UuGQ\r\n2q8cm0_WfI\r\nZR63WSVBlC\r\ndtO9nmkXsc\r\ntHL2amBqOS\r\n', 'output': ['6 2\r\n']}, {'input': 'NNNIIIIIINN\r\n10\r\nNNIIIIIIN\r\nIIIINN\r\nIIIINN\r\nNNIIIII\r\nNNII\r\nlHJxS_HfkO\r\nPsss2tjeao\r\nY4Adt_8FXb\r\nkc9mq2vWmZ\r\nVJYusUjoTq\r\n', 'output': ['8 2\r\n']}, {'input': 'cCCcCCCcCccc\r\n10\r\ncC\r\nCCcCCCcCc\r\nCCcC\r\ncCc\r\ncCCC\r\npUKBhDtW8W\r\n0ap4vlgGej\r\nk059r28XMJ\r\nySQTZIOz3r\r\nFHn5rVpM8G\r\n', 'output': ['4 8\r\n']}, {'input': '7hh77hhhhhh7h\r\n10\r\nhhhh7\r\nhh77hhhhh\r\n7hhhhh\r\nhh7\r\nh77hhhhhh7\r\nC_t1uIxLWp\r\nHwH5EkVGCt\r\nyUgWASGwfR\r\nRfah5Fa12E\r\nS9CmGvTVKM\r\n', 'output': ['7 2\r\n']}, {'input': '3cc3\r\n10\r\ncc\r\nc3\r\n3c\r\ncc\r\ncc\r\n3cc3\r\n3cc3\r\n3cc\r\nc3\r\njLnOy3kI3M\r\n', 'output': ['1 3\r\n']}, {'input': '70aa70a\r\n10\r\n70\r\n0aa70\r\n0aa70\r\naa70\r\n70aa\r\n70aa\r\n70aa70a\r\naa7\r\n70aa7\r\nicHuodu1Ux\r\n', 'output': ['3 1\r\n']}, {'input': 'YUYEYEUUEU\r\n10\r\nYEYEUUEU\r\nEUUE\r\nUU\r\nYEYEUUE\r\nYEYE\r\nUU\r\nEY\r\nEYEUU\r\nYEYEUU\r\niBXoTbQ7X3\r\n', 'output': ['4 0\r\n']}, {'input': 'wwwwDwwwwD\r\n10\r\nwD\r\nDwww\r\nwD\r\nDwwww\r\nwwwwD\r\nDww\r\nwD\r\nwwDww\r\nwwww\r\nwwww\r\n', 'output': ['3 6\r\n']}, {'input': '4tg4ttgg47t44tg4ttgg47t4\r\n10\r\n47t44tg4tt\r\nttgg4\r\ng4ttgg47t4\r\ng47t44t\r\ntg4ttg\r\n44tg4ttg\r\nttgg47\r\nt44tg\r\ng47t44tg\r\n4ttgg47t4\r\n', 'output': ['8 5\r\n']}, {'input': 'g0sg00AAA0Asggss0sAg0sg00AAA0Asggss0sA\r\n10\r\nAg0sg00AAA\r\nAsggss\r\nsAg\r\nAsggss0s\r\nggss0sAg\r\nsAg0sg\r\nggss0sA\r\n0sg00AA\r\nAAA0A\r\nAA0\r\n', 'output': ['8 18\r\n']}, {'input': '000gooo0g0vgovvv0oggv0v0go000gooo0g0vgovvv0oggv0v0go\r\n10\r\ngv0v0go\r\n0gooo0g\r\ngooo0g0v\r\no000\r\ngooo0g0v\r\nv0go000go\r\ngo000gooo0\r\nv0v0go00\r\nvv\r\nggv0v0\r\n', 'output': ['10 30\r\n']}, {'input': 'B2KR\r\n10\r\nB2\r\n2KR\r\nB2KR\r\n2K\r\n2KR\r\nKR\r\n2KR\r\nB2KR\r\n2K\r\n2KR\r\n', 'output': ['1 3\r\n']}, {'input': 'dxY_8\r\n10\r\nxY_8\r\ndxY\r\ndx\r\nY_\r\nxY_\r\ndx\r\nxY\r\ndx\r\nxY_8\r\ndxY\r\n', 'output': ['2 3\r\n']}, {'input': 'umi4qX\r\n10\r\nqX\r\num\r\n4qX\r\nqX\r\numi4qX\r\numi4\r\numi4\r\numi4q\r\nmi4q\r\numi4q\r\n', 'output': ['3 2\r\n']}, {'input': '4stuNRe\r\n10\r\n4stu\r\nstuN\r\nstuNRe\r\n4stu\r\ntuNRe\r\nst\r\ntuNR\r\n4stuN\r\ntuN\r\n4stu\r\n', 'output': ['4 3\r\n']}, {'input': 'bTnstTqbTnstTq\r\n10\r\nbTnstTq\r\nnstTqbT\r\nTqbT\r\nbTns\r\nTqbT\r\nTns\r\nTnstT\r\nTnstTqb\r\nnstT\r\nstT\r\n', 'output': ['4 6\r\n']}, {'input': 'Oq02utSVOq02utSV\r\n10\r\n2utSVOq\r\n2utSVO\r\n02utS\r\nSVOq0\r\nut\r\nOq\r\nOq\r\nq02utSVO\r\nOq02utSV\r\nVOq0\r\n', 'output': ['4 9\r\n']}, {'input': 'DpGGt6_wGLPDpGGt6_wGLP\r\n10\r\n6_wGL\r\nGLPDpGG\r\nt6_wG\r\nPDpGGt6_\r\nwGLPDpGGt6\r\n6_\r\n_wGL\r\npGGt6_\r\n6_wGLPD\r\n6_wGLPDpG\r\n', 'output': ['8 9\r\n']}, {'input': '7QTfE4ALvzkzzD4j7QTfE4ALvzkzzD4j\r\n10\r\nvzkzzD4j7\r\nE4AL\r\nTfE4ALv\r\nzzD4j7QT\r\nzkzzD4j7\r\n4AL\r\nj7Q\r\nE4ALvzkzzD\r\nvzkzzD4j\r\n4ALvzk\r\n', 'output': ['9 22\r\n']}, {'input': '6CLznedj88834gqTIhMTPjm_3DbkQpuYkBvU3o55h79ntRqjHTOu3WWNNGLyQSZ_o45mK5mMtRJmWUq2twqWP10OlnDAB1EP2rG\r\n10\r\n834gqTI\r\n_o4\r\nvU3o55h79n\r\nvLwlk3PY7Z\r\nk8PnkBpRYB\r\nqdkB9b_SS2\r\nkY4mBeAdgK\r\nb577cjQiSx\r\nyOFiEkP1sD\r\noYOqd8uuTt\r\n', 'output': ['35 64\r\n']}, {'input': 'JroK3tfp941zeUovVIqCV7Sv2elf6TN8QRl8mhxQWgoQRXOLkcUjK29Ed2gBDR1TLdZeLUi9zJyBayrNlWgW0iPSG26DuJ9QK95\r\n10\r\nroK\r\novVI\r\nLUi9\r\nLUi\r\nTLd\r\nelf6\r\n9zJyBa\r\nDR1\r\ndZe\r\n8mhxQWgo\r\n', 'output': ['27 72\r\n']}, {'input': 'p7B41t9y83IghcJG8zgWzCSATkkvQQhvqm7j_4ffUPbriGW57mbGPzqiuMEmJevfIhX2FNLFBxAGm3vLXRPOdphoWkCquDjAsW9\r\n10\r\n1t9y83\r\nBxAGm3v\r\nG8z\r\nCSATk\r\ncJG\r\nIhX2FNLF\r\nzqiuME\r\np7B4\r\nkkvQ\r\nPbriGW57m\r\n', 'output': ['26 73\r\n']}, {'input': 'r5oW1NW2kr193KwV_eASuj9Jq0q0Kmt2EUD1R72p2nPuxNpIqi7o_KuxldYjLJmiXj93JUxRTniFzKkXxHwXDZCzC76klFnfjAQ\r\n10\r\np2nPuxN\r\n93J\r\nNpIqi7o_K\r\niXj93JUxRT\r\n1NW2kr19\r\n0Kmt2EUD1\r\nTniFzKkXxH\r\niXj93JU\r\nNW2kr19\r\n3KwV_\r\n', 'output': ['26 73\r\n']}, {'input': 'hb\r\n1\r\nAa\r\n', 'output': ['2 0\r\n']}, {'input': 'unagioisiiqqqqqqqqqqqq\r\n2\r\nioi\r\nunagi\r\n', 'output': ['17 5\r\n']}, {'input': 'abababab\r\n3\r\nab\r\nba\r\na\r\n', 'output': ['1 7\r\n']}, {'input': 'abcdaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n2\r\nabcd\r\nabcd\r\n', 'output': ['50 1\r\n']}, {'input': 'abababababababababababababababababababababababababababababab\r\n1\r\na\r\n', 'output': ['1 59\r\n']}, {'input': 'abc\r\n2\r\na\r\nb\r\n', 'output': ['1 2\r\n']}, {'input': 'abcde\r\n1\r\nf\r\n', 'output': ['5 0\r\n']}, {'input': 'ahmed\r\n5\r\nahmed\r\nhmed\r\nmed\r\ned\r\nd\r\n', 'output': ['4 0\r\n']}, {'input': 'abc\r\n1\r\nb\r\n', 'output': ['1 2\r\n']}]


#include <stdio.h>
#include <string.h>

#define maxN   100010
#define maxLog     50

#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int Min[maxN][maxLog];
int	Max[maxN][maxLog];
int sol[maxN][2], a[maxN];

int main( void ) {
	int n, k;
	scanf("%i %i", &n, &k);

	int i, j;
	for( i = 0; i < n; i++ )
		scanf("%i", &a[i]);

	for( i = 0; i < n; i++ )
		Min[i][0] = Max[i][0] = a[i];

	for( j = 1; (1 << j) <= n; j++ )
		for( i = 0; i + (1 << j) - 1 < n; i++ ) {
				Min[i][j] = min(Min[i][j-1], Min[i + (1 << (j-1))][j-1]);
				Max[i][j] = max(Max[i][j-1], Max[i + (1 << (j-1))][j-1]);
			}

	int lo = 1, hi = n, len, ans = 0, sz = 0;
	while( lo <= hi ) {
		len = (lo + hi) / 2;

		int cnt = 0, log = 31 - __builtin_clz(len);
		for( i = 0, j = len -1; i <= n-len; i++, j = i + len - 1 ) {
			int maxElement = max(Max[i][log], Max[j-(1 << log)+1][log]),
				minElement = min(Min[i][log], Min[j-(1 << log)+1][log]);

			if( maxElement - minElement <= k ) {
				sol[cnt][0] = i;
				sol[cnt][1] = i + len - 1;
				cnt += 1;
			}
		}

		if( cnt > 0 ) {
			ans = len;
			sz = cnt;
			lo = len + 1;
		}
		else {
			hi = len - 1;
		}

	}

	printf("%i %i\n", ans, sz);
	for( i = 0; i < sz; i++ )
		printf("%i %i\n", sol[i][0] + 1, sol[i][1] + 1);

	return 0;
}


#include <stdio.h>
#include <string.h>

#define MAXN 110

short g[MAXN][5];
short c[MAXN];
short v[MAXN];
short p[MAXN];
short f[MAXN][MAXN];

void recur(int cur, int num)
{
    int i;
    v[cur] = num;
    for (i = 0; i < c[cur]; i ++)
    {
        if (v[g[cur][i]] == -1)
        {
            recur(g[cur][i], num);
        }
    }
}

void solve(int n)
{
    int i, num;
    memset(v, 255, sizeof(v));
    num = 0;
    for (i = 0; i < n; i ++)
    {
        if (v[i] == -1)
        {
            recur(i, num);
            num ++;
        }
    }
    for (i = 0; i < n; i ++)
    {
        if (v[i] != v[p[i] - 1])
        {
            printf("NO\n");
            return;
        }
    }
    printf("YES\n");
}

int main()
{
    int n, i, d;
    while (scanf("%d", &n) == 1)
    {
        for (i = 0; i < n; i ++)
        {
            scanf("%hd", &p[i]);
        }
        memset(c, 0, sizeof(c));
        memset(f, 0, sizeof(f));
        for (i = 0; i < n; i ++)
        {
            scanf("%d", &d);
            if (i - d >= 0 && f[i - d][i] == 0)
            {
                g[i - d][c[i - d] ++] = i;
                g[i][c[i] ++] = i - d;
                f[i - d][i] = f[i][i - d] = 1;
            }
            if (i + d < n && f[i][i + d] == 0)
            {
                g[i + d][c[i + d] ++] = i;
                g[i][c[i] ++] = i + d;
                f[i + d][i] = f[i][i + d] = 1;
            }
        }
        solve(n);
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAXN 100007
#define MOD 1000000007

struct node
{
	int l, r, val, sum;
};

void sort (struct node a[MAXN], int l, int r)
{
	int i, j, x;
	struct node y;
	i = l; j = r; x = a[(l+r)/2].r;
	while (i <= j)
	{
		while (a[i].r < x) i++;
		while (a[j].r > x) j--;
		if (i <= j)
		{
			y = a[i]; a[i] = a[j]; a[j] = y;
			i++; j--;
		}
	}
	if (l < j) sort(a,l,j);
	if (i < r) sort(a,i,r);
}

int main ()
{
	int L, N;
	scanf("%d %d",&L,&N);
	static struct node a[MAXN];
	a[0].l = -1;
	a[0].r = -1;
	a[0].val = 0;
	a[0].sum = 0;
	a[1].l = 0;
	a[1].r = 0;
	a[1].val = 1;
	a[1].sum = 1;
	int i;
	N += 2;
	for (i = 2; i < N; i++)
	{
		scanf("%d %d",&(a[i].l),&(a[i].r));
	}
	sort(a,2,N-1);
	int l, r, c, what;
	int X, Y;
	int res = 0;
	for (i = 2; i < N; i++)
	{
		what = a[i].l;
		l = 1; r = i;
		while (r > l)
		{
			c = (l+r)/2;
			if (a[c].r >= what) r = c;
			else l = c+1;
		}
		X = l;

		what = a[i].r;
		l = 1; r = i;
		while (r > l)
		{
			c = (l+r)/2;
			if (a[c].r >= what) r = c;
			else l = c+1;
		}
		Y = l;

		a[i].val = (a[Y-1].sum - a[X-1].sum + MOD) % MOD;
		a[i].sum = (a[i-1].sum + a[i].val) % MOD;

		if (a[i].r == L)
		{
			res = (res + a[i].val) % MOD;
		}
	}
	printf("%d\n",res);
	return 0;
}


#include <stdio.h>

int knights[100500], n;

char check(int k) {
    int start, j;
    if(n / k < 3)
        return 0;
    for(start = 0; start < k; start++) {
        char isHappy = 1;
        for(j = start; isHappy && j < n; j += k) {
            if(knights[j] == 0) {
                isHappy = 0;
            }
        }
        if(isHappy)
            return 1;
    }
    return 0;
}

int main() {
    int i, j;
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%d", knights + i);
    }
    for(i = 1; (long long)(i) * i <= n; i++) {
        if(n % i)
            continue;
        if(check(i) || check(n / i)) {
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}


#include <stdio.h>

#define MAXN 100010
#define EPS 1e-6
#define DIMS 2

int N,M;

double A[MAXN][2];
double B[MAXN][2];

double cross(double *a,double *b)
{
    return (a[0])*(b[1])-(a[1])*(b[0]);
}

void sub(double *res,double *a,double *b)
{
    int i;
    for(i=0;i<DIMS;i++)
        res[i]=a[i]-b[i];
}

double abso(double a)
{
    return (a<0)?-a:a;
}

char verify(int index,int i,int j)
{
    double edge[2];
    double point[2];
    sub(edge,A[j],A[i]);
    sub(point,B[index],A[i]);
    if (cross(point,edge)>EPS)
        return 1;
    else
        return 0;
}

char binary_search(int index)
{
    double b[2];
    double m_b[2];
    double m[2];
    double m_a[2];
    sub(b,B[index],A[0]);
    int mid;
    int lo=1,hi=N-1;
    while(lo<=hi)
    {
        mid=lo + (hi-lo)/2;
        sub(m,A[mid],A[0]);
        if (mid>0)
        {
            sub(m_b,A[mid-1],A[0]);
            if(abso(cross(b,m))<EPS || abso(cross(b,m_b))<EPS || (cross(b,m)*cross(b,m_b))<0)
            {
                if (!verify(index,mid-1,mid))
                    return 0;
                else
                    return 1;
            }
        }
        if (mid<N-1)
        {
            sub(m_a,A[mid+1],A[0]);
            if(abso(cross(b,m))<EPS || abso(cross(b,m_a))<EPS || (cross(b,m)*cross(b,m_a))<0)
            {
                if (!verify(index,mid,mid+1))
                    return 0;
                else
                    return 1;
            }
        }
        if (cross(b,m)<0)
            hi=mid-1;
        else
            lo=mid+1;
    }
    /*error*/
    return -1;
}

int main()
{
    int i;
    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%lf %lf",&A[i][0],&A[i][1]);
    scanf("%d",&M);
    for(i=0;i<M;i++)
        scanf("%lf %lf",&B[i][0],&B[i][1]);
    double tmp[2];
    double f[2];
    double s[2];
    char flag=0;
    for(i=0;i<M;i++)
    {
        sub(tmp,B[i],A[0]);
        sub(f,A[1],A[0]);
        sub(s,A[N-1],A[0]);
        if (cross(tmp,f)<EPS)
        {
            flag=1;
            break;
        }
        if (cross(tmp,s)>-EPS)
        {
            flag=1;
            break;
        }
        if (!binary_search(i))
        {
            flag=1;
            break;
        }
    }
    if (flag)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, m, h, s[1002];

    scanf("%d%d%d",&n,&m,&h);

    int i, sum = 0;

    for (i = 1; i <= m; i++)
    {
        scanf("%d",&s[i]);
        sum += s[i];
    }

    n--;
    sum--;
    s[h]--;

    double ver = 1.0, j;

    if (sum < n) printf("-1.0");
    else
    {
        if (sum - s[h] < n) printf("1.0");
        else
        {
            j = (sum - s[h] - n + 1);
            for (i = sum - s[h] + 1; i <= sum; i++)
            {
                ver *= j/i;
                j += 1;
            }
            printf("%f",1.0 - ver);
        }
    }
    return 0;
}


using System;
using System.Linq;
namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int n= int.Parse(Console.ReadLine());
            int[] a= Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int m = int.Parse(Console.ReadLine());
            int[] b= Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int count = 0;
            int max = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    if (b[j]%a[i]==0)
                    {
                        int rez = b[j] / a[i];
                        if (rez>max)
                        {
                            max = rez;
                            count=1;
                        }
                        else if (rez==max)
                        {
                            count++;
                        }
                    }
                }
            }
            Console.WriteLine(count) ;
        }
    }
}


using System;
using System.Collections.Generic;

class Solve
{
    private double dist(int x1, int y1, int x2, int y2)
    {
        return Math.Sqrt((double)(x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    }

    private int cmp(double a, double b)
    {
        if (a + 1e-6 < b)
            return -1;
        if (a - 1e-6 > b)
            return +1;
        return 0;
    }

    public void solve()
    {
        string[] In = Console.ReadLine().Split(new char[] { ' ' });
        int n = int.Parse(In[0]);
        int vb = int.Parse(In[1]);
        int vs = int.Parse(In[2]);

        In = Console.ReadLine().Split(new char[] { ' ' });
        int[] x = new int[n];
        for (int i = 0; i < n; ++i)
            x[i] = int.Parse(In[i]);

        In = Console.ReadLine().Split(new char[] { ' ' });
        int xu = int.Parse(In[0]);
        int yu = int.Parse(In[1]);

        double[] d = new double[n];
        double[] t = new double[n];

        for (int i = 0; i < n; ++i)
        {
            d[i] = dist(x[i], 0, xu, yu);
            t[i] = (double)x[i] / vb + d[i] / vs;
        }

        int num = n - 1;
        for (int i = 1; i < n; ++i)
            if ((cmp(t[i], t[num]) == -1) || ((cmp(t[i], t[num]) == 0) && (cmp(d[i], d[num]) == -1)))
                num = i;

        Console.WriteLine("{0}", num + 1);
    }

}

class Program
{
    static void Main()
    {
        Solve Task = new Solve();
        Task.solve();
       // Console.ReadKey();
    }
}


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

namespace contest
{

    class contest
    {

        static void Main(string[] args)
        {

            //int n = int.Parse(Console.ReadLine());
            //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int n = int.Parse(Console.ReadLine());
            var num = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var prizes = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var ans = new long[5];
            long point = 0;
            for(int i=0; i< n; i++)
            {
                point += num[i];
                for(int j=4; j>=0; j--)
                {
                    long p = prizes[j];
                    if(point>= p)
                    {
                        ans[j] += point / p;
                        point -= (point / p)*p;
                    }
                }
            }

            Console.WriteLine(string.Join(" ",ans));
            Console.WriteLine(point);

        }

    }

}


using System;
using System.IO;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
    class Program
    {
        string nextToken()
        {
            string str = "";
            int c;
            do
            {
                c = Console.Read();
                if (c == -1 || ((char)c != ' ' && (char)c != '\n' && (char)c != '\r' && (char)c != '\t')) break;
            } while (true);
            if (c == -1) return str;
            while (true)
            {
                str += (char)c;
                c = Console.Read();
                if (c == -1 || (char)c == ' ' || (char)c == '\n' || (char)c == '\r' || (char)c == '\t') break;
            }
            return str;
        }

        int nextInt()
        {
            return int.Parse(nextToken());
        }

        double nextDouble()
        {
            return double.Parse(nextToken());
        }

        void Solve()
        {
            int n = nextInt(), k = nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            int res = 0;
            while (a[0] < k)
            {
                for (int i = 0; i < n && a[i] < k; )
                {
                    int j = i;
                    for (; j < n && a[j] == a[i]; j++) ;
                    i = j;
                    a[j - 1]++;
                }
                res++;
            }
            Console.Write(res);
        }

        static void Main(string[] args)
        {
#if MY_SUPER_PUPER_ONLINE_JUDGE
            string dir = Directory.GetCurrentDirectory();
            dir = Directory.GetParent(dir).FullName;
            dir = Directory.GetParent(dir).FullName;
            Console.SetIn(new StreamReader(dir + "\\input.txt"));
            Console.SetOut(new StreamWriter(dir + "\\output.txt"));
#endif
            new Program().Solve();
#if MY_SUPER_PUPER_ONLINE_JUDGE
            Console.In.Close();
            Console.Out.Close();
#endif
        }
    }
}


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

namespace ProgrammingContest.Codeforces.Round80
{
    class B
    {
        static int[] ReadInts() { return Console.ReadLine().Split(' ').Select<string, int>(int.Parse).ToArray(); }

        static bool[] used;
        static List<int>[] e;
        static Stack<int> vis = new Stack<int>();
        static HashSet<int> roots = new HashSet<int>();
        static bool find;
        static int count = 0;

        static int edge(int u, int v) { return Math.Max(u, v) * 1000 + Math.Min(u, v); }

        static bool dfs(int idx)
        {
            int prev = vis.Any() ? vis.Peek() : -1;
            used[idx] = true;
            count++;
            vis.Push(idx);
            //Console.Write("edge: {0}:", idx + 1);
            //foreach (int i in e[idx])                Console.Write(" {0}", i + 1);
            //Console.WriteLine();
            foreach (int i in e[idx])
            {
                //Console.WriteLine("checked: {0} -> {1}", idx+1, i+1);
                if (!used[i])
                {
                    if (!dfs(i))
                        return false;
                }
                else if (prev != i)
                {
                    //Console.WriteLine("prev: {0} != {1}", prev+ 1, i + 1);
                    if (find)
                    {
                        //Console.WriteLine("infind: {0}", roots.Contains(edge(idx, i)));
                        if (!roots.Contains(edge(idx, i)))
                            return false;
                        continue;
                    }
                    find = true;
                    List<int> xs = new List<int>();
                    foreach (var v in vis)
                    {
                        xs.Add(v);
                        if (v == i)
                            break;
                    }
                    for (int j = 0; j < xs.Count; j++)
                    {
                        //Console.WriteLine("check: {0} {1}", xs[j], xs[j+1]);
                        roots.Add(edge(xs[j], xs[(j + 1) % xs.Count]));
                    }
                }
            }
            vis.Pop();
            return true;
        }

        static void Main()
        {
            var xs = ReadInts();
            int n = xs[0],
                m = xs[1];

            used = new bool[n];
            e = new List<int>[n];
            for (int i = 0; i < n; i++)
                e[i] = new List<int>();

            for (int i = 0; i < m; i++)
            {
                xs = ReadInts();
                for (int j = 0; j < 2; j++)
                    e[xs[j] - 1].Add(xs[j ^ 1] - 1);
            }

            Console.WriteLine(dfs(0) && find && count==n ? "FHTAGN!" : "NO");
        }
    }
}


namespace topCoder
{
	using System;
	using System.Collections.Generic;

	class p2
	{
		static void Main(string[] args)
		{
			//p1 o = new p1();
			//o.foo();

			p2 o = new p2();
			o.foo();
		}
		public void foo()
		{
			int n = int.Parse(Console.ReadLine());
			bool[] inRoom = new bool[1000002];
			int p = 0, soFar = 0;
			string[] e = new string[n];
			bool[] seen = new bool[1000002];
			for (int i = 0; i < n; i++)
			{
				e[i] = Console.ReadLine();
				string[] sp = e[i].Split(' ');
				int x = int.Parse(sp[1]);
				if (sp[0] == "-")
				{
					if (!seen[x])
					{
						p++;
						inRoom[x] = true;
					}
				}
				seen[x] = true;
			}
			soFar = p;
			for (int i = 0; i < n; i++)
			{
				string[] sp = e[i].Split(' ');
				int x = int.Parse(sp[1]);
				if (sp[0] == "+")
				{
					p++;
					inRoom[x] = true;
				}
				else
				{
					p--;
					inRoom[x] = false;
				}
				soFar = Math.Max(soFar, p);
			}

			Console.WriteLine(soFar);
		}
	}
}


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

namespace codeforces
{
	class Program
	{
		public const int Osn = 1000000007;

		public class Pair
		{
			public long First;

			public long Second;
		}

		public class PairComparer : IComparer<Pair>
		{
			public int Compare(Pair x, Pair y)
			{
				if (x.First < y.First || (x.First == y.First && x.Second > y.Second))
					return -1;
				return 1;
			}
		}

		public static long GetGcd(long a, long b)
		{
			while (true)
			{
				if (b == 0)
					return a;
				var a1 = a;
				a = b;
				b = a1 % b;
			}
		}

		public static void WriteYesNo(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string ReadString()
		{
			return Console.ReadLine();
		}

		public static List<int> ReadListOfInts()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static List<long> ReadListOfLongs()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(long.Parse).ToList();
		}

		public static int ReadInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static long ReadLong()
		{
			var s = Console.ReadLine();
			return long.Parse(s);
		}

		public class Vertex
		{
			public int Was;

			public List<int> Edges;
		}

		public static List<Vertex> Graph = new List<Vertex>();

		public static bool Dfs(int u)
		{
			if (Graph[u].Was == 1) return true;
			if (Graph[u].Was == 2) return false;
			Graph[u].Was = 1;
			foreach (var t in Graph[u].Edges)
			{
				if (Dfs(t)) return true;
			}

			Graph[u].Was = 2;
			return false;
		}

		public static bool IsPrime(int x)
		{
			for (var j = 2; j * j <= x; ++j)
				if (x % j == 0)
					return false;
			return true;
		}

		public class LinkedVertex
		{
			public int Next;

			public int Prev;

			public int Value;
		}

		public static int BinarySearch(List<int> list, int value)
		{
			var l = -1;
			var r = list.Count;
			while (r - l > 1)
			{
				var m = (r + l) / 2;
				if (list[m] >= value)
					r = m;
				else
					l = m;
			}

			return r;
		}

		private static void Main()
		{
			var l = ReadListOfInts();
			var n = l[0];
			var a = l[1];
			var b = l[2];

			var ans = new int[a, b];
			for (var i = 0; i < a; ++i)
				for (var j = 0; j < b; ++j)
					ans[i, j] = 0;
			var ct = 1;
			var t = 0;
			for (var i = 0; i < a; ++i)
				for (var j = 0; j < b; ++j)
				{
					if (ct <= n && i % 2 == j % 2)
					{
						ans[i, j] = ct;
						ct += 2;
						t++;
					}
				}
			ct = 2;
			for (var i = 0; i < a; ++i)
				for (var j = 0; j < b; ++j)
				{
					if (ct <= n && i % 2 != j % 2)
					{
						ans[i, j] = ct;
						ct += 2;
						t++;
					}
				}
			if (t != n)
				Console.WriteLine(-1);
			else
			{
				for (var i = 0; i < a; ++i)
				{
					for (var j = 0; j < b; ++j)
					{
						Console.Write("{0} ", ans[i, j]);
					}
					Console.WriteLine();
				}
			}
			Console.ReadLine();
		}
	}
}


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

namespace Ejercicio6
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            string phoneNumber;
            string result = " ";

            n = Convert.ToInt32(Console.ReadLine());
            phoneNumber = Console.ReadLine();

            if (n >= 2 && n <= 100)
            {
                if(n % 2 == 0)
                {
                    result = Regex.Replace(phoneNumber, ".{2}", "$0-");
                    result = result.Substring(0, result.Length - 1);
                }
                else
                {
                    string aux;
                    string numero;
                    int tam = phoneNumber.Length;

                    aux = phoneNumber.Substring(0, 3);
                    phoneNumber = phoneNumber.Remove(0, aux.Length);
                    numero = aux;
                    tam = tam - aux.Length;

                    while (tam != 0)
                    {
                        aux = phoneNumber.Substring(0, 2);
                        phoneNumber = phoneNumber.Remove(0, aux.Length);
                        numero = numero + "-" + aux;
                        tam = tam - aux.Length;
                    }
                    result = numero;
                }
            }
            Console.WriteLine(result);
        }
    }
}


namespace Csharp_Contest
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Globalization;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading;
/*
 * #import_IntegerMatrix.cs
 */
    static class Program
    {
        private static int mod = (int)(1e9) + 7;

        static void Solve()
        {
            long n = NextLong();
            IntegerMatrix matrix = new IntegerMatrix(2, mod);
            matrix.Reset();
            matrix[0, 0] = 3;
            matrix[0, 1] = 1;
            matrix[1, 0] = 1;
            matrix[1, 1] = 3;
            var ans = matrix ^ n;
            Console.WriteLine(ans[0, 0]);
        }

        public static void Main(string[] args)
        {
#if CLown1331
            for (int testCase = 0; testCase < 3; testCase++)
            {
                Solve();
            }

            Utils.CreateFileForSubmission();
            if (Debugger.IsAttached) Thread.Sleep(Timeout.Infinite);
#else
            if (args.Length == 0)
            {
                Console.SetOut(new Printer(Console.OpenStandardOutput()));
            }

            Thread t = new Thread(Solve, 134217728);
            t.Start();
            t.Join();
            Console.Out.Flush();
#endif
        }

        static int NextInt() => int.Parse(Console_.NextString());
        static long NextLong() => long.Parse(Console_.NextString());
        static double NextDouble() => double.Parse(Console_.NextString());
        static string NextString() => Console_.NextString();
        static string NextLine() => Console.ReadLine();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }

        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString()
            {
                if (param.Count == 0)
                {
                    foreach (string item in NextLine().Split(' '))
                    {
                        param.Enqueue(item);
                    }
                }
                return param.Dequeue();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider => CultureInfo.InvariantCulture;
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
    }
}
namespace Csharp_Contest
{
/*
 * #import_Matrix.cs
 */
    public class IntegerMatrix: Matrix<int>
    {
        private readonly int mod;

        public IntegerMatrix(int size, int mod) : base(size)
        {
            this.mod = mod;
        }

        public override void Identity()
        {
            for (int i = 0; i < this.Size; i++)
            {
                for (int j = 0; j < this.Size; j++)
                {
                    this[i, j] = (i == j) ? 1 : 0;
                }
            }
        }

        protected override Matrix<int> Add(Matrix<int> right)
        {
            IntegerMatrix temp = new IntegerMatrix(this.Size, this.mod);
            temp.Reset();
            for (int i = 0; i < this.Size; i++)
            {
                for (int j = 0; j < this.Size; j++)
                {
                    temp[i, j] = (this[i, j] + right[i, j]) % this.mod;
                    while (temp[i, j] >= this.mod)
                    {
                        temp[i, j] -= this.mod;
                    }
                }
            }

            return temp;
        }

        protected override Matrix<int> Multiply(Matrix<int> right)
        {
            IntegerMatrix temp = new IntegerMatrix(this.Size, this.mod);
            temp.Reset();
            for (int i = 0; i < this.Size; i++)
            {
                for (int j = 0; j < this.Size; j++)
                {
                    for (int k = 0; k < this.Size; k++)
                    {
                        temp[i, k] += (int)((1L * this[i, j] * right[j, k]) % this.mod);
                        while (temp[i, k] >= this.mod)
                        {
                            temp[i, k] -= this.mod;
                        }
                    }
                }
            }

            return temp;
        }

        protected override Matrix<int> Power(long power)
        {
            IntegerMatrix ans = new IntegerMatrix(this.Size, this.mod);
            ans.Identity();
            IntegerMatrix num = this;
            for (; power > 0; power >>= 1)
            {
                if (power % 2 == 1)
                {
                    ans = (IntegerMatrix)(ans * num);
                }

                num = (IntegerMatrix)(num * num);
            }

            return ans;
        }
    }
}
namespace Csharp_Contest
{
    public abstract class Matrix<T>
    {
        private T[,] a;
        private readonly int size;

        protected Matrix(int size)
        {
            this.size = size;
            this.a = new T[this.size, this.size];
        }

        public void Reset()
        {
            for (int i = 0; i < this.size; i++)
            {
                for (int j = 0; j < this.size; j++)
                {
                    this[i, j] = default(T);
                }
            }
        }

        public abstract void Identity();

        public static Matrix<T> operator+ (Matrix<T> a, Matrix<T> b)
        {
            return a.Add(b);
        }

        protected abstract Matrix<T> Add(Matrix<T> right);

        public static Matrix<T> operator *(Matrix<T> a, Matrix<T> b)
        {
            return a.Multiply(b);
        }

        protected abstract Matrix<T> Multiply(Matrix<T> right);

        public static Matrix<T> operator ^(Matrix<T> a, long power)
        {
            return a.Power(power);
        }

        public static Matrix<T> operator ^(Matrix<T> a, int power)
        {
            return a.Power(power);
        }

        public T this[int i, int j]
        {
            get => this.a[i, j];
            set => this.a[i, j] = value;
        }

        protected abstract Matrix<T> Power(long power);

        public int Size => this.size;
    }
}


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

namespace ContestRuns
{
    class Program
    {
        public class Rec
        {

        }
        public class Comparer : IComparer<Rec>
        {
            public int Compare(Rec x, Rec y)
            {
                throw new NotImplementedException();
            }
        }

#if DEBUG
        static readonly TextReader input = File.OpenText(@"../../A/A.in");
        static readonly TextWriter output = File.CreateText(@"../../A/A.out");
#else
        static readonly TextReader input = Console.In;
        static readonly TextWriter output = Console.Out;
#endif

        private static void SolveA()
        {
            long n = long.Parse(input.ReadLine());
            var inp = input.ReadLine().Split(new char[] { ':' }).Select(long.Parse).ToArray();

            string res1 = "", res2 = "";
            if (n == 12)
            {
                int mmin = -1;
                for (int a = 1; a <= 12; ++a)
                {
                    int cur = 0;
                    if ((a % 10) != (inp[0] % 10)) cur += 1;
                    if ((a / 10) != (inp[0] / 10)) cur += 1;
                    if (cur < mmin || mmin == -1)
                    {
                        res1 = (a / 10) + "" + (a % 10);
                        mmin = cur;
                    }
                }
            }
            else
            {
                int mmin = -1;
                for (int a = 0; a <= 23; ++a)
                {
                    int cur = 0;
                    if ((a % 10) != (inp[0] % 10)) cur += 1;
                    if ((a / 10) != (inp[0] / 10)) cur += 1;
                    if (cur < mmin || mmin == -1)
                    {
                        res1 = (a / 10) + "" + (a % 10);
                        mmin = cur;
                    }
                }
            }
            int mmin2 = -1;
            for (int a = 0; a <= 59; ++a)
            {
                int cur = 0;
                if ((a % 10) != (inp[1] % 10)) cur += 1;
                if ((a / 10) != (inp[1] / 10)) cur += 1;
                if (cur < mmin2 || mmin2 == -1)
                {
                    res2 = (a / 10) + "" + (a % 10);
                    mmin2 = cur;
                }
            }
            output.WriteLine(res1 + ":" + res2);
        }

        static void Main(string[] args)
        {
            SolveA();
            output.Flush();
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Linq;

namespace Codeforces
{
    internal static class Program
    {
        private const string TEST = "C3";

        private static void Solve()
        {
            var input = ReadLongArray();
            var l = input[0];
            var r = input[1];
            var dp = new long[20];
            dp[1] = 1;
            dp[2] = 1;
            long pow = 10;
            for (int i = 3; i <= 19; i++)
            {
                dp[i] = pow;
                pow *= 10;
            }
            long res = Get(r, dp) - Get(l - 1, dp);
            WriteLine(res);
        }

        private static long Get(long n, long[] dp)
        {
            if (n == 0)
                return 0;
            if (n < 10)
                return n;

            long res = 0;
            var count = 0;
            var initN = n;
            var first = 0L;
            while (n > 0)
            {
                count++;
                first = n;
                n /= 10;
            }
            for (int i = 1; i < count; i++)
            {
                res += 9 * dp[i];
            }
            res += (first - 1) * dp[count];
            n = initN;
            n -= first * (long)Math.Pow(10, count - 1);
            while (n % 10 != first && n > 0)
            {
                n--;
            }
            res += n / 10 + (n != 0 ? 1 : 0);

            return res;
        }

        private static void Main()
        {
            if (Debugger.IsAttached)
            {
                Console.SetIn(new StreamReader(String.Format(@"..\..\..\..\Tests\{0}.in", TEST)));
            }

            Solve();

            if (Debugger.IsAttached)
            {
                Console.In.Close();
                Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                Console.ReadLine();
            }
        }

        #region Reader

        private static string Read()
        {
            return Console.ReadLine();
        }

        private static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static List<int> ReadIntArray()
        {
            var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToList();
            return input;
        }

        private static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }

        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        private static List<long> ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
        }

        private static double ReadDouble()
        {
            return double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
        }

        private static List<double> ReadDoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();
        }

        private static void WriteLine(object value)
        {
            Console.WriteLine(value);
        }

        private static void WriteLine(int value)
        {
            Console.WriteLine(value);
        }

        private static void WriteLine(double value)
        {
            Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void WriteLine(long value)
        {
            Console.WriteLine(value);
        }

        private static void WriteLine(double value, string stringFormat)
        {
            Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void Write(object value)
        {
            Console.Write(value);
        }

        private static void Write(int value)
        {
            Console.Write(value);
        }

        private static void Write(double value)
        {
            Console.Write(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void Write(long value)
        {
            Console.Write(value);
        }

        private static void Write(double value, string stringFormat)
        {
            Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }
        #endregion
    }
}


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

namespace CodeForces
{
    public class CodeForcesClass
    {
        public static void Main()
        {
            var items = ReadList<int>();
            var n = items[0];
            var l = items[1];
            var blinds = ReadList<int>();
            var max = 0;
            for (var i = l; i <= 100; i++)
            {
                var count = 0;
                foreach (var blind in blinds)
                {
                    count += blind / i;
                }
                max = Math.Max(max, count*i);
            }
            Console.WriteLine(max);
        }

        // Here goes misc

        public static T Read<T>()
        {
            var line = Console.ReadLine();
            var item = Convert.ChangeType(line, typeof (T));
            return (T) item;
        }

        public static List<T> ReadList<T>(char[] delimiters = null)
        {
            var line = Read<string>();
            var split = line.Split(delimiters ?? new[] {' '});
            var list = split.Select(item => (T) Convert.ChangeType(item, typeof (T))).ToList();
            return list;
        }

        public static List<T> ReadListNlines<T>(int n, char[] delimiters = null)
        {
            var list = new List<T>();
            for (var i = 0; i < n; i++)
            {
                list.Add(Read<T>());
            }
            return list;
        }

        public static void ReadFromFile()
        {
            Console.SetIn(new StreamReader(@"..\..\input.txt"));
        }

        public static bool NextPermutation<T>(T[] items) where T : IComparable
        {
            var i = -1;
            for (var x = items.Length - 2; x >= 0; x--)
            {
                if (items[x].CompareTo(items[x + 1]) < 0)
                {
                    i = x;
                    break;
                }
            }

            if (i == -1)
            {
                return false;
            }
            var j = 0;
            for (var x = items.Length - 1; x > i; x--)
            {
                if (items[x].CompareTo(items[i]) > 0)
                {
                    j = x;
                    break;
                }
            }
            var temp = items[i];
            items[i] = items[j];
            items[j] = temp;
            Array.Reverse(items, i + 1, items.Length - (i + 1));
            return true;
        }

        public static string ReplaceChar(string str, char c, int idx)
        {
            return str.Substring(0, idx) + c + str.Substring(idx + 1);
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
static class P {
    static int[] ToIntArray(this string val) { return val.Split().Select(int.Parse).ToArray(); }
    static void Main() {
        var line = Console.ReadLine().ToIntArray();
        int n = line[0], t = line[1], i = 0, cnt = 0;
        var list = new SortedList<int, int>();
        for (; i < n; ++i) {
            var input = Console.ReadLine().ToIntArray();
            list.Add(input[0], input[1]);
        }

        IList<int> keys = list.Keys, values = list.Values;
        for (i = 0; i < n - 1; ++i) {
            var val = (keys[i + 1] - keys[i]) - ((values[i + 1] + values[i]) / 2.0);
            if (val > t) { cnt += 2; } else if (val == t) { cnt++; }
        }
        Console.Write(cnt + 2);
    }
}


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

namespace _217A
{
    class Struct
    {
        public Struct(int x1, int y1, int set1)
        {

            x = x1;
            y = y1;
            set = set1;
        }
        public int x;
        public int y;
        public int set;

        public override string ToString()
        {
            return x + " " + y + " " + set;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var list = new List<Struct>();

            int id = 0;

            for (int i = 0; i < n; i++)
            {
                //Console.WriteLine("Точка №"+i);
                var strArr = Console.ReadLine().Split(' ');
                int x = int.Parse(strArr[0]);
                int y = int.Parse(strArr[1]);
                var setValue = list.Where(s => s.x == x ^ s.y == y).Select(s => s.set).ToArray();
                var setElems = list.Where(s => setValue.Contains(s.set)).ToArray();
                foreach (var item in setElems)
                {
                    item.set = id;
                }
                list.Add(new Struct(x, y, id));
                id++;
                //foreach (var item in list)
                //{
                //    Console.WriteLine(item.ToString());
                //}
            }
            Console.WriteLine(list.Select(s=>s.set).Distinct().Count()-1);
        }
    }
}


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

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

        private static void Main(string[] args)
        {
            int n = Next();
            int m = Next();

            var nn = new List<int>[n + 1];
            for (int i = 0; i < nn.Length; i++)
            {
                nn[i] = new List<int>();
            }
            for (int i = 0; i < m; i++)
            {
                int a = Next();
                int b = Next();
                nn[a].Add(b);
                nn[b].Add(a);
            }
            var counts = new int[nn.Length];
            for (int i = 0; i < nn.Length; i++)
            {
                counts[i] = nn[i].Count;
            }

            int count = 0;
            while (true)
            {
                var todel = new List<int>();
                for (int i = 0; i < nn.Length; i++)
                {
                    if (counts[i] == 1)
                    {
                        todel.Add(i);
                    }
                }
                if (todel.Count == 0)
                    break;

                count++;

                foreach (int i in todel)
                {
                    counts[i] = 0;
                    foreach (int j in nn[i])
                    {
                        if (counts[j] > 0)
                            counts[j]--;
                    }
                }
            }

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


using System;
using System.Collections.Generic;

public class Program {
    private int n;
    private int[] numbers;

    public void Solve() {
        string[] data;
        data = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        n = int.Parse(data[1]);
        data = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        numbers = new int[data.Length];
        for (int i = 0; i < numbers.Length; ++i)
            numbers[i] = int.Parse(data[i]);
        Console.WriteLine(computeMinCost());
    }

    private int computeMinCost() {
        Array.Sort(numbers);
        if (numbers.Length > 0 && numbers[0] == 1)
            return n == 2 ? 0 : 1;
        else if (n >= limit)
            return -1;
        int cost = 0, index = 0;
        foreach (int prime in primes) {
            if (prime >= n)
                break;
            while (index < numbers.Length && numbers[index] < prime)
                ++index;
            if (index == numbers.Length || numbers[index] != prime)
                return -1;
            ++cost;
        }
        return cost;
    }

    private static int limit = 1299744;
    private static bool[] isPrime;
    private static List<int> primes;

    private static void computePrimes() {
        isPrime = new bool[limit];
        for (int i = 2; i < limit; ++i)
            isPrime[i] = true;
        primes = new List<int>();
        for (int i = 2; i < limit; ++i) {
            if (isPrime[i])
                primes.Add(i);
            foreach (int prime in primes) {
                if (i * prime >= limit)
                    break;
                isPrime[i * prime] = false;
                if (i % prime == 0)
                    break;
            }
        }
    }

    public static void Main() {
        computePrimes();
        new Program().Solve();
    }
}


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

namespace AlgoTraining.Codeforces.C_s
{

    public class FastScanner : StreamReader
    {
        private string[] _line;
        private int _iterator;

        public FastScanner(Stream stream) : base(stream)
        {
            _line = null;
            _iterator = 0;
        }
        public int NextInt()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return Convert.ToInt32(_line[_iterator++]);
        }
        public long NextLong()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return Convert.ToInt64(_line[_iterator++]);
        }
    }
    class InternationalOlympiad347
    {
        public static string Beg = "1989";
        public static long BegNum = 1989;
        public static void Main(string[] args)
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                int n = fs.NextInt();
                string[] reqs = new string[n];
                for (int i = 0; i < n; i++)
                {
                    reqs[i] = fs.ReadLine().Split('\'')[1];
                }
                for (int i = 0; i < n; i++)
                {
                    long num = Convert.ToInt64(FirstOccurence(reqs[i]));
                    while (!CheckIfUsed(num, reqs[i].Length))
                    {
                        num += (long)Math.Pow(10, reqs[i].Length);
                    }
                    writer.WriteLine(num);
                }
            }
        }
        public static string FirstOccurence(string suffix)
        {
            if (suffix.Length > Beg.Length) return suffix;
            else if (suffix.Length == Beg.Length)
            {
                if (Convert.ToInt64(suffix) >= BegNum) return suffix;
                else return "1" + suffix;
            }
            else
            {
                long t = Convert.ToInt64(Beg.Substring(0, Beg.Length - suffix.Length) + suffix);
                if (t >= BegNum) return t.ToString();
                else return (t + Math.Pow(10, suffix.Length)).ToString();
            }
        }
        public static bool CheckIfUsed(long num, int sufLen)
        {
            for (int i = sufLen - 1; i > 0; i--)
            {
                num -= (long) Math.Pow(10, i);
                if ( num < BegNum) return false;
            }
            return true;
        }
    }
}