package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadBytes('\n')
	var n, m int
	pos := readInt(line, 0, &n)
	pos = readInt(line, pos+1, &m)
	var k int
	readInt(line, pos+3, &k)
	before := make([]string, n)

	for i := 0; i < n; i++ {
		before[i] = readString(reader)
	}

	after := make([]string, m)

	for i := 0; i < m; i++ {
		after[i] = readString(reader)
	}

	res := solve(k, before, after)

	var buf bytes.Buffer

	buf.WriteString(fmt.Sprintf("%d\n", len(res)))

	for i := 0; i < len(res); i++ {
		buf.WriteString(res[i])
		buf.WriteByte('\n')
	}

	fmt.Print(buf.String())
}

func readFloat64(bs []byte, pos int, r *float64) int {
	var first float64
	var second float64
	exp := 1.0
	var dot bool
	for pos < len(bs) && (bs[pos] == '.' || isDigit(bs[pos])) {
		if bs[pos] == '.' {
			dot = true
		} else if !dot {
			first = first*10 + float64(bs[pos]-'0')
		} else {
			second = second*10 + float64(bs[pos]-'0')
			exp *= 10
		}
		pos++
	}
	*r = first + second/exp
	//fmt.Fprintf(os.Stderr, "%.6f ", *r)
	return pos
}

func isDigit(b byte) bool {
	return b >= '0' && b <= '9'
}

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

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

	return i
}

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

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

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

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

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

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

func solve(k int, before []string, after []string) []string {
	skills := make(map[string]int)

	//K := int(k * 100)

	for _, s := range before {
		var i int
		for i < len(s) && s[i] != ' ' {
			i++
		}
		name := s[:i]
		i++
		var score int
		readInt([]byte(s), i, &score)
		score = k * score / 100
		if score >= 100 {
			skills[name] = score
		}
	}

	var res []string

	for _, s := range after {
		sc := skills[s]
		res = append(res, fmt.Sprintf("%s %d", s, sc))
		delete(skills, s)
	}

	for s, v := range skills {
		res = append(res, fmt.Sprintf("%s %d", s, v))
	}

	sort.Strings(res)

	return res
}

[{'input': ['5 4 0.75\r\naxe 350\r\nimpaler 300\r\nionize 80\r\nmegafire 120\r\nmagicboost 220\r\nheal\r\nmegafire\r\nshield\r\nmagicboost\r\n'], 'output': ['6\r\naxe 262\r\nheal 0\r\nimpaler 225\r\nmagicboost 165\r\nmegafire 0\r\nshield 0\r\n']}, {'input': ['1 1 0.50\r\nstaff 1005\r\nionize\r\n'], 'output': ['2\r\nionize 0\r\nstaff 502\r\n']}, {'input': ['4 3 0.32\r\ninrf 48\r\nfdgdf 200\r\nvbkdfk 450\r\nfdbvfdd 1000\r\ndff\r\ninrf\r\nnfdkd\r\n'], 'output': ['5\r\ndff 0\r\nfdbvfdd 320\r\ninrf 0\r\nnfdkd 0\r\nvbkdfk 144\r\n']}, {'input': ['5 1 0.99\r\na 1\r\nb 2\r\nc 3\r\nd 4\r\ne 5\r\nf\r\n'], 'output': ['1\r\nf 0\r\n']}, {'input': ['2 2 0.02\r\nfn 1003\r\nzz 7000\r\nkk\r\nau\r\n'], 'output': ['3\r\nau 0\r\nkk 0\r\nzz 140\r\n']}, {'input': ['3 3 0.10\r\naa 900\r\nbb 990\r\ncc 999\r\naa\r\nbb\r\ncc\r\n'], 'output': ['3\r\naa 0\r\nbb 0\r\ncc 0\r\n']}, {'input': ['1 1 0.99\r\nfdvedvrgfckdkvfpmkjd 100\r\nfdvedvrgfckdkvfpmkjd\r\n'], 'output': ['1\r\nfdvedvrgfckdkvfpmkjd 0\r\n']}, {'input': ['1 1 0.01\r\na 9999\r\na\r\n'], 'output': ['1\r\na 0\r\n']}, {'input': ['1 1 0.80\r\nxyz 125\r\nxyz\r\n'], 'output': ['1\r\nxyz 100\r\n']}, {'input': ['5 1 0.67\r\ndjdn 6699\r\nolkj 6700\r\nhgvg 6698\r\noijggt 6701\r\nyfyv 6700\r\nyfyv\r\n'], 'output': ['5\r\ndjdn 4488\r\nhgvg 4487\r\noijggt 4489\r\nolkj 4489\r\nyfyv 4489\r\n']}, {'input': ['5 2 0.73\r\njcyuc 136\r\npooj 137\r\nojnbg 138\r\ninng 135\r\nuuv 139\r\nhg\r\nouohoiivuvu\r\n'], 'output': ['5\r\nhg 0\r\nojnbg 100\r\nouohoiivuvu 0\r\npooj 100\r\nuuv 101\r\n']}, {'input': ['4 1 0.99\r\nutctc 101\r\nijh 100\r\nfyyui 99\r\ntctxxx 102\r\nojohiobib\r\n'], 'output': ['2\r\nojohiobib 0\r\ntctxxx 100\r\n']}, {'input': ['4 4 0.80\r\nyfcyccyyccccc 123\r\nkkkkk 124\r\noops 125\r\nabfgg 126\r\nh\r\njkl\r\nqwerty\r\noops\r\n'], 'output': ['5\r\nabfgg 100\r\nh 0\r\njkl 0\r\noops 100\r\nqwerty 0\r\n']}, {'input': ['4 6 0.68\r\na 146\r\nb 147\r\nc 148\r\nd 149\r\ne\r\nf\r\ng\r\nh\r\ni\r\nj\r\n'], 'output': ['8\r\nc 100\r\nd 101\r\ne 0\r\nf 0\r\ng 0\r\nh 0\r\ni 0\r\nj 0\r\n']}, {'input': ['5 1 0.02\r\nirn 4999\r\nsdfc 5000\r\nzzzzzz 5001\r\ndcw 100\r\nfvvv 22\r\ndcw\r\n'], 'output': ['3\r\ndcw 0\r\nsdfc 100\r\nzzzzzz 100\r\n']}, {'input': ['5 5 0.18\r\nxwjxvrgz 9492\r\ndhpe 5259\r\nbnbkznfgyuluho 5070\r\nygpluaefwefxmhuaqi 2975\r\nvqstuwkaqk 8892\r\ndhpe\r\nbnbkznfgyuluho\r\nygpluaefwefxmhuaqi\r\nvyaefiicj\r\nxwjxvrgz\r\n'], 'output': ['6\r\nbnbkznfgyuluho 912\r\ndhpe 946\r\nvqstuwkaqk 1600\r\nvyaefiicj 0\r\nxwjxvrgz 1708\r\nygpluaefwefxmhuaqi 535\r\n']}, {'input': ['10 10 0.28\r\nszyiekxcixeyqyfm 7701\r\ncdxkfpggugy 5344\r\ngqyvyzwkajhc 3674\r\ntmo 8865\r\ntbp 8932\r\nwbrzxccfmdxbzw 4566\r\nvpgcejyragzhm 1554\r\ncqqjrh 7868\r\nw 1548\r\nxkbitfl 588\r\nlpcwvverv\r\nborcfgittei\r\nw\r\nzqtzpicsndbxfcbaduds\r\ncdxkfpggugy\r\ntmo\r\nmvmdaltjmy\r\nbzhykrayudljyj\r\nyktrcowlgwkvqucbqh\r\nvtm\r\n'], 'output': ['17\r\nborcfgittei 0\r\nbzhykrayudljyj 0\r\ncdxkfpggugy 1496\r\ncqqjrh 2203\r\ngqyvyzwkajhc 1028\r\nlpcwvverv 0\r\nmvmdaltjmy 0\r\nszyiekxcixeyqyfm 2156\r\ntbp 2500\r\ntmo 2482\r\nvpgcejyragzhm 435\r\nvtm 0\r\nw 433\r\nwbrzxccfmdxbzw 1278\r\nxkbitfl 164\r\nyktrcowlgwkvqucbqh 0\r\nzqtzpicsndbxfcbaduds 0\r\n']}, {'input': ['13 13 0.20\r\nbbdtfrykzf 6189\r\nnqwei 7327\r\ndtigwnbwevnnlinhk 3662\r\nxokqjtylly 1274\r\nsdpnhipam 5672\r\npfjmflvtuvctwxr 9580\r\nybqgomvwoguzcqvzkx 2062\r\nvowzavh 6345\r\nbfidjslqlesdtyjkreou 6780\r\nsvpzwtwn 1945\r\ninvzueipnifajadhjk 7034\r\nsz 6494\r\nce 1323\r\nybqgomvwoguzcqvzkx\r\nbbdtfrykzf\r\nvunbpghae\r\ndtigwnbwevnnlinhk\r\nuqdlfskhgo\r\nvdemdnxifb\r\nvowzavh\r\npfjmflvtuvctwxr\r\nbfidjslqlesdtyjkreou\r\nnqwei\r\nsz\r\njiemqkytxtqnxgjvhzjl\r\nce\r\n'], 'output': ['17\r\nbbdtfrykzf 1237\r\nbfidjslqlesdtyjkreou 1356\r\nce 264\r\ndtigwnbwevnnlinhk 732\r\ninvzueipnifajadhjk 1406\r\njiemqkytxtqnxgjvhzjl 0\r\nnqwei 1465\r\npfjmflvtuvctwxr 1916\r\nsdpnhipam 1134\r\nsvpzwtwn 389\r\nsz 1298\r\nuqdlfskhgo 0\r\nvdemdnxifb 0\r\nvowzavh 1269\r\nvunbpghae 0\r\nxokqjtylly 254\r\nybqgomvwoguzcqvzkx 412\r\n']}, {'input': ['1 17 0.97\r\nsfidbvqbvx 562\r\npmuvtjkw\r\nysxuhhfgwgifkf\r\nnsgdgacfdstvsf\r\ngggnzgevrtykq\r\nvmeytgyobqpmq\r\nrbzif\r\nfqbr\r\nepcy\r\ntvtgk\r\nsdwsny\r\nhuzsrlvxvufyb\r\niallwqylqga\r\nsemxysiafu\r\nodrxgpjgiiizlubtuv\r\nlenenatgyqep\r\nlzakhvoxfccct\r\nijkhhuppdghdwz\r\n'], 'output': ['18\r\nepcy 0\r\nfqbr 0\r\ngggnzgevrtykq 0\r\nhuzsrlvxvufyb 0\r\niallwqylqga 0\r\nijkhhuppdghdwz 0\r\nlenenatgyqep 0\r\nlzakhvoxfccct 0\r\nnsgdgacfdstvsf 0\r\nodrxgpjgiiizlubtuv 0\r\npmuvtjkw 0\r\nrbzif 0\r\nsdwsny 0\r\nsemxysiafu 0\r\nsfidbvqbvx 545\r\ntvtgk 0\r\nvmeytgyobqpmq 0\r\nysxuhhfgwgifkf 0\r\n']}, {'input': ['5 19 0.38\r\nmwfhslniu 2324\r\njyzifusxbigcagch 6167\r\nkccudxutkgb 9673\r\nuccmkylmiqcn 4773\r\niuawwcyefaimhro 214\r\njyzifusxbigcagch\r\nfalsionuewiyvseurg\r\nrkrvudkrhophdflqln\r\nahsybnxitvpm\r\nx\r\nancpcxgr\r\nsvs\r\nvvssivqobhdfqggahqu\r\npf\r\nwjtrtcvjqydxuwwvsqpc\r\nyllpzfjdojpymwy\r\nepjhkxffsymowea\r\nyztamblsfzk\r\nbej\r\nwy\r\nvnkvonk\r\nymsnsngzcvxeilbitknn\r\nlmaajt\r\nmwfhslniu\r\n'], 'output': ['21\r\nahsybnxitvpm 0\r\nancpcxgr 0\r\nbej 0\r\nepjhkxffsymowea 0\r\nfalsionuewiyvseurg 0\r\njyzifusxbigcagch 2343\r\nkccudxutkgb 3675\r\nlmaajt 0\r\nmwfhslniu 883\r\npf 0\r\nrkrvudkrhophdflqln 0\r\nsvs 0\r\nuccmkylmiqcn 1813\r\nvnkvonk 0\r\nvvssivqobhdfqggahqu 0\r\nwjtrtcvjqydxuwwvsqpc 0\r\nwy 0\r\nx 0\r\nyllpzfjdojpymwy 0\r\nymsnsngzcvxeilbitknn 0\r\nyztamblsfzk 0\r\n']}, {'input': ['13 10 0.35\r\napjqdcdylyads 948\r\ni 618\r\nsbifpsvflzngfziwx 6815\r\nlhuzbitj 8455\r\nzhoro 657\r\nfm 6899\r\nbhigr 6743\r\net 3322\r\nljbkmxj 3023\r\nloxxykp 6048\r\naiibfjdgd 965\r\nmmpylhw 5483\r\nyrbikjks 7426\r\nfm\r\njvj\r\napjqdcdylyads\r\nbhigr\r\naiibfjdgd\r\nljbkmxj\r\nauftuqyphmz\r\nloxxykp\r\nzhoro\r\ndmqdfmfjq\r\n'], 'output': ['16\r\naiibfjdgd 337\r\napjqdcdylyads 331\r\nauftuqyphmz 0\r\nbhigr 2360\r\ndmqdfmfjq 0\r\net 1162\r\nfm 2414\r\ni 216\r\njvj 0\r\nlhuzbitj 2959\r\nljbkmxj 1058\r\nloxxykp 2116\r\nmmpylhw 1919\r\nsbifpsvflzngfziwx 2385\r\nyrbikjks 2599\r\nzhoro 229\r\n']}, {'input': ['17 6 0.44\r\nhefojxlinlzhynuleh 9008\r\nufy 7485\r\ngmgjrihvgxsbcu 7575\r\nrnlz 3789\r\nnkvcpt 5813\r\nm 9066\r\nsjxpwpxrkbpydkjcojvq 8679\r\nftvk 9385\r\nyygdlclq 759\r\nvkltswaflkg 5183\r\notosgwfe 639\r\nmaayvyqtvxkudpbcfj 7425\r\nhys 935\r\ngwucwol 6087\r\nbrkmjhnmmrkjzhar 1247\r\ntea 205\r\nhyxhj 6600\r\nmaayvyqtvxkudpbcfj\r\nm\r\nrnlz\r\nbrkmjhnmmrkjzhar\r\nhys\r\ngwucwol\r\n'], 'output': ['16\r\nbrkmjhnmmrkjzhar 548\r\nftvk 4129\r\ngmgjrihvgxsbcu 3333\r\ngwucwol 2678\r\nhefojxlinlzhynuleh 3963\r\nhys 411\r\nhyxhj 2904\r\nm 3989\r\nmaayvyqtvxkudpbcfj 3267\r\nnkvcpt 2557\r\notosgwfe 281\r\nrnlz 1667\r\nsjxpwpxrkbpydkjcojvq 3818\r\nufy 3293\r\nvkltswaflkg 2280\r\nyygdlclq 333\r\n']}, {'input': ['19 3 0.40\r\npwmgdtn 817\r\nikzw 8809\r\nyjltrwizoumwvvtivqmm 2126\r\ntvdguvmepsvvp 9945\r\ndvhoxdvqyqmyl 5998\r\nalpxryere 7048\r\nchnprj 3029\r\ntnsrxilkay 1076\r\nquamvicl 7260\r\nzdzahaxmxnbkuqavmb 174\r\nywgyrbmmhwbrcx 3637\r\noicdsxki 7516\r\nzftrgvmtbuhqsmv 6831\r\njlfjgvzgmkmzbsjhwhy 8042\r\nzuy 2049\r\nhsahihp 1975\r\nkcfsycnilwqyqvsf 6896\r\ntdlgs 4302\r\nim 4476\r\nkcfsycnilwqyqvsf\r\nim\r\ndvhoxdvqyqmyl\r\n'], 'output': ['18\r\nalpxryere 2819\r\nchnprj 1211\r\ndvhoxdvqyqmyl 2399\r\nhsahihp 790\r\nikzw 3523\r\nim 1790\r\njlfjgvzgmkmzbsjhwhy 3216\r\nkcfsycnilwqyqvsf 2758\r\noicdsxki 3006\r\npwmgdtn 326\r\nquamvicl 2904\r\ntdlgs 1720\r\ntnsrxilkay 430\r\ntvdguvmepsvvp 3978\r\nyjltrwizoumwvvtivqmm 850\r\nywgyrbmmhwbrcx 1454\r\nzftrgvmtbuhqsmv 2732\r\nzuy 819\r\n']}, {'input': ['20 1 0.78\r\nxc 6799\r\nztrfjsq 3023\r\nkhbcbsaztwigxeidh 2974\r\nkksvbmtjiiqlguwv 188\r\nwvqzzjrpmxsdbfvua 4547\r\niqkqqwtqifdpxfhslpv 6264\r\nwarmknju 9472\r\nfheisuiufwmtagl 292\r\nwge 4338\r\nzaklermeji 6733\r\nfcn 6282\r\nbjyjzgzkgzy 1778\r\ngufpvhdnsesyfuegef 4998\r\nxnhuhwzzxqbaphktqbc 8485\r\ncokabaqahfw 8645\r\nbtgeopbwekffdadgj 1791\r\nsgvrgyhidnhecvt 7264\r\ncczstyyxhbpwj 3244\r\nguaykdl 3786\r\nmabamfnewwrykizn 4705\r\nbjyjzgzkgzy\r\n'], 'output': ['20\r\nbjyjzgzkgzy 1386\r\nbtgeopbwekffdadgj 1396\r\ncczstyyxhbpwj 2530\r\ncokabaqahfw 6743\r\nfcn 4899\r\nfheisuiufwmtagl 227\r\nguaykdl 2953\r\ngufpvhdnsesyfuegef 3898\r\niqkqqwtqifdpxfhslpv 4885\r\nkhbcbsaztwigxeidh 2319\r\nkksvbmtjiiqlguwv 146\r\nmabamfnewwrykizn 3669\r\nsgvrgyhidnhecvt 5665\r\nwarmknju 7388\r\nwge 3383\r\nwvqzzjrpmxsdbfvua 3546\r\nxc 5303\r\nxnhuhwzzxqbaphktqbc 6618\r\nzaklermeji 5251\r\nztrfjsq 2357\r\n']}, {'input': ['1 1 0.94\r\na 8700\r\nb\r\n'], 'output': ['2\r\na 8178\r\nb 0\r\n']}, {'input': ['1 1 0.70\r\na 1000\r\na\r\n'], 'output': ['1\r\na 700\r\n']}, {'input': ['2 1 0.50\r\naxe 200\r\nmegafire 120\r\nmegafire\r\n'], 'output': ['2\r\naxe 100\r\nmegafire 0\r\n']}, {'input': ['5 4 0.99\r\naxe 350\r\nimpaler 300\r\nionize 102\r\nmegafire 120\r\nmagicboost 220\r\nheal\r\nmegafire\r\nshield\r\nmagicboost\r\n'], 'output': ['7\r\naxe 346\r\nheal 0\r\nimpaler 297\r\nionize 100\r\nmagicboost 217\r\nmegafire 118\r\nshield 0\r\n']}, {'input': ['1 1 0.94\r\na 8700\r\nb\r\n'], 'output': ['2\r\na 8178\r\nb 0\r\n']}, {'input': ['1 1 0.50\r\nlho 200\r\nhai\r\n'], 'output': ['2\r\nhai 0\r\nlho 100\r\n']}, {'input': ['20 3 0.29\r\na 100\r\nb 200\r\nc 300\r\nd 400\r\ne 500\r\nf 600\r\ng 700\r\nh 800\r\ni 900\r\nj 1000\r\nk 1100\r\nl 1200\r\nm 1300\r\nn 1400\r\no 1500\r\np 1600\r\nq 1700\r\nr 1800\r\ns 1900\r\nt 2000\r\nz\r\nm\r\nk\r\n'], 'output': ['18\r\nd 116\r\ne 145\r\nf 174\r\ng 203\r\nh 232\r\ni 261\r\nj 290\r\nk 319\r\nl 348\r\nm 377\r\nn 406\r\no 435\r\np 464\r\nq 493\r\nr 522\r\ns 551\r\nt 580\r\nz 0\r\n']}, {'input': ['2 2 0.50\r\nabcd 200\r\naaa 201\r\nfff\r\nffff\r\n'], 'output': ['4\r\naaa 100\r\nabcd 100\r\nfff 0\r\nffff 0\r\n']}, {'input': ['1 1 0.94\r\na 8700\r\nb\r\n'], 'output': ['2\r\na 8178\r\nb 0\r\n']}, {'input': ['1 1 0.29\r\nhren 400\r\nblin\r\n'], 'output': ['2\r\nblin 0\r\nhren 116\r\n']}, {'input': ['5 4 0.30\r\naxe 350\r\nimpaler 9000\r\nionize 80\r\nmegafire 120\r\nmagicboost 220\r\nheal\r\nmegafire\r\nshield\r\nmagicboost\r\n'], 'output': ['6\r\naxe 105\r\nheal 0\r\nimpaler 2700\r\nmagicboost 0\r\nmegafire 0\r\nshield 0\r\n']}, {'input': ['1 1 0.03\r\naxe 9900\r\nheal\r\n'], 'output': ['2\r\naxe 297\r\nheal 0\r\n']}]


package main

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

var n, m, k, nn, mm int
var a map[int]map[int]bool = make(map[int]map[int]bool)
var b map[int]map[int]bool = make(map[int]map[int]bool)

func culc1(x, y int) (ok, end bool, xx, yy int) {
	if m < mm {
		return true, true, 0, 0
	}
	if haveA, have := a[x]; have {
		miny := m + 1
		num := 0
		for ay, _ := range haveA {
			if ay >= mm && ay <= m {
				miny = min(ay, miny)
				num++
			}
		}

		if num+miny != m+1 {
			return false, true, 0, 0
		}

		for i := miny; i <= m; i++ {
			numx := 0
			for ax, _ := range b[i] {
				if ax >= nn && ax <= n {
					numx++
				}
			}
			if numx+nn != n+1 {
				return false, true, 0, 0
			}
		}
		return true, false, x, miny - 1
	}

	return true, false, x, m
}

func culc2(x, y int) (ok, end bool, xx, yy int) {
	if n < nn {
		return true, true, 0, 0
	}

	if haveA, have := b[y]; have {
		minx := n + 1
		numx := 0
		for ax, _ := range haveA {
			if ax >= x && ax <= n {
				minx = min(ax, minx)
				numx++
			}
		}

		if numx+minx != n+1 {
			return false, true, 0, 0
		}

		for i := minx; i <= n; i++ {
			numy := 0
			for ay, _ := range a[i] {
				if ay >= mm && ay <= m {
					numy++
				}
			}
			if numy+mm != m+1 {
				return false, true, 0, 0
			}
		}
		return true, false, minx - 1, y
	}

	return true, false, n, m
}

func culc3(x, y int) (ok, end bool, xx, yy int) {
	if m < mm {
		return true, true, 0, 0
	}

	if haveA, have := a[x]; have {
		maxy := mm - 1
		num := 0
		for ay, _ := range haveA {
			if ay >= mm && ay <= m {
				maxy = max(ay, maxy)
				num++
			}
		}

		if maxy+1 != mm+num {
			return false, true, 0, 0
		}

		for i := mm; i <= maxy; i++ {
			numx := 0
			for ax, _ := range b[i] {
				if ax >= nn && ax <= n {
					numx++
				}
			}
			if numx+nn != n+1 {
				return false, true, 0, 0
			}
		}
		return true, false, x, maxy + 1
	}

	return true, false, n, mm
}

func culc4(x, y int) (ok, end bool, xx, yy int) {
	if n < nn {
		return true, true, 0, 0
	}

	if haveA, have := b[y]; have {
		maxx := nn - 1
		num := 0
		for ax, _ := range haveA {
			if ax >= nn && ax <= n {
				maxx = max(ax, maxx)
				num++
			}
		}

		if maxx+1 != nn+num {
			return false, true, 0, 0
		}

		for i := nn; i <= maxx; i++ {
			numy := 0
			for ay, _ := range a[i] {
				if ay >= mm && ay <= m {
					numy++
				}
			}
			if numy+mm != m+1 {
				return false, true, 0, 0
			}
		}
		return true, false, maxx + 1, y
	}

	return true, false, nn, y
}

func min(x, y int) int {
	if x < y {
		return x
	}

	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}

	return y
}

func main() {

	reader := bufio.NewReader(os.Stdin)

	fmt.Fscanf(reader, "%d %d %d\n", &n, &m, &k)

	var x, y int
	for i := 1; i <= k; i++ {
		fmt.Fscanf(reader, "%d %d\n", &x, &y)
		if _, ok := a[x]; !ok {
			a[x] = make(map[int]bool)
		}

		if _, ok := b[y]; !ok {
			b[y] = make(map[int]bool)
		}

		a[x][y] = true
		b[y][x] = true
	}

	x = 1
	y = 1
	nn = 1
	mm = 1
	ok := true
	end := false
	for ok && !end {
		ok, end, x, y = culc1(x, y)
		//fmt.Println("culc1", ok, end, x, y)
		if !ok || end {
			break
		}
		m = y
		nn++

		ok, end, x, y = culc2(x, y)
		//fmt.Println("culc2", ok, end, x, y)
		if !ok || end {
			break
		}

		m--
		n = x

		ok, end, x, y = culc3(x, y)
		//fmt.Println("culc3", ok, end, x, y)
		if !ok || end {
			break
		}

		n--
		mm = y

		ok, end, x, y = culc4(x, y)
		//fmt.Println("culc4", ok, end, x, y)
		if !ok || end {
			break
		}

		mm++
		nn = x
	}

	if ok {
		fmt.Printf("Yes\n")
	} else {
		fmt.Printf("No\n")
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1292C(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, v, w int
	Fscan(in, &n)
	g := make([][]int, n)
	for i := 1; i < n; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	pa := make([][3000]int16, n)
	sz := make([][3000]int16, n)
	for i := range pa {
		var f func(int16, int16)
		f = func(v, fa int16) {
			pa[i][v] = fa
			sz[i][v] = 1
			for _, w := range g[v] {
				if w := int16(w); w != fa {
					f(w, v)
					sz[i][v] += sz[i][w]
				}
			}
		}
		f(int16(i), -1)
	}

	dp := make([][3000]int64, n)
	var f func(int16, int16) int64
	f = func(v, w int16) int64 {
		if v == w {
			return 0
		}
		if dp[v][w] == 0 {
			dp[v][w] = max(f(pa[w][v], w), f(v, pa[v][w])) + int64(int(sz[v][w])*int(sz[w][v]))
		}
		return dp[v][w]
	}
	ans := int64(0)
	for v := int16(0); v < int16(n); v++ {
		for w := v + 1; w < int16(n); w++ {
			ans = max(ans, f(v, w))
		}
	}
	Fprint(out, ans)
}

func main() { CF1292C(os.Stdin, os.Stdout) }

func max(a, b int64) int64 {
	if b > a {
		return b
	}
	return a
}


package main

import (
	"fmt"
)

func main() {
	var N, M, i, j int
	fmt.Scanf("%d %d", &N, &M)
	fmt.Scanf("%d %d", &i, &j)

	// Calculate the expected number of steps
	n := float64(N)
	m := float64(M)
	x := float64(i)
	y := float64(j)
	e := (n - x) * (m - y) / (x * y)

	fmt.Printf("%.10f\n", e)
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	points := make([][2]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&points[i][0], &points[i][1])
	}

	// Calculate the total area
	totalArea := 0.0
	for i := 0; i < n; i++ {
		j := (i + 1) % n
		totalArea += float64(points[i][0]*points[j][1] - points[j][0]*points[i][1])
	}
	totalArea = math.Abs(totalArea) / 2.0

	// Calculate the sum of squares of distances from the origin to each point
	sumSquareDistances := 0.0
	for _, point := range points {
		sumSquareDistances += float64(point[0]*point[0] + point[1]*point[1])
	}

	// Calculate the expected area
	expectedArea := totalArea / sumSquareDistances

	fmt.Printf("%.10f\n", expectedArea)
}


package main

import "fmt"

var (
	n           int
	num         []int64
	par         []int
	rem         []int64
	minCount    int = 1e9
	delimsCache     = make(map[int64]int)
)

func countPrimeDelims(n int64) (count int) {
	if val, ok := delimsCache[n]; ok {
		count = val
		return
	}
	n0 := n
	for ; n%2 == 0; n /= 2 {
		count++
	}
	for p := int64(3); p*p <= n; p += 2 {
		for ; n%p == 0; n /= p {
			count++
		}
	}
	if n > 1 {
		count++
	}
	delimsCache[n0] = count
	return
}

func eval() {
	count := 0
	withPar0 := 0
	for p := 1; p <= n; p++ {
		delimCount := countPrimeDelims(rem[p])
		if delimCount == 1 && num[p] == rem[p] { // rem[p] is prime and p does not have kids
			count += 1
		} else {
			count += delimCount + 1
		}
		if par[p] == 0 {
			withPar0++
		}
	}
	if withPar0 > 1 {
		count++
	}
	if count < minCount {
		minCount = count
	}
}

func brute(i int) {
	if i == n+1 {
		eval()
		return
	}
	par[i] = 0
	brute(i + 1)

	for p := 1; p <= n; p++ {
		if p != i && num[i] <= rem[p] && rem[p]%num[i] == 0 {
			par[i] = p
			rem[p] /= num[i]
			brute(i + 1)
			rem[p] *= num[i]
		}
	}
}

func main() {
	fmt.Scan(&n)
	num = make([]int64, n+1)
	par = make([]int, n+1)
	rem = make([]int64, n+1)
	for i := 1; i <= n; i++ {
		fmt.Scan(&num[i])
		rem[i] = num[i]
	}
	brute(1)
	fmt.Println(minCount)
}


package main

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

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func scan(a ...interface{}) (n int, err error)             { return fmt.Fscan(in, a...) }
func scanf(f string, a ...interface{}) (n int, err error)  { return fmt.Fscanf(in, f, a...) }
func printf(f string, a ...interface{}) (n int, err error) { return fmt.Fprintf(out, f, a...) }

//https://codeforces.com/problemset/problem/5/D

func main() {
	defer out.Flush()

	var a, v, l, d, w float64
	scanf("%f %f\n", &a, &v)
	scanf("%f %f %f\n", &l, &d, &w)

	if v > w {
		if s := w * w / 2 / a; s <= d {
			peak := math.Sqrt(a*d + w*w/2)
			t1 := 0.0
			if peak <= v {
				t1 = (2*peak - w) / a
			} else {
				t1 = (2*v-w)/a + (d-(v*v-w*w/2)/a)/v
			}
			printf("%.6f\n", t1+getTime(w, v, a, l-d))
		} else {
			printf("%.6f\n", getTime(0, v, a, l))
		}
	} else {
		printf("%.6f\n", getTime(0, v, a, l))
	}
}

func getTime(v0, maxV, a, l float64) float64 {
	if s := (maxV*maxV - v0*v0) / 2 / a; s <= l {
		return (maxV-v0)/a + (l-s)/maxV
	}
	return (math.Sqrt(v0*v0+2*a*l) - v0) / a
}


package main

import "fmt"

type Matrix struct {
	x [][]uint64
}

func newMatrix(dx int, dy int) Matrix {
	var r Matrix
	r.x = make([][]uint64, dx)
	for i := 0; i < dx; i++ {
		r.x[i] = make([]uint64, dy)
	}
	return r
}

func (r *Matrix) setValue(dx int, dy int, val uint64) {
	r.x[dx][dy] = val
}

func (r Matrix) multi(r1 Matrix, m uint64) Matrix {
	res := newMatrix(2, 2)
	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			for k := 0; k < 2; k++ {
				res.x[i][j] = (res.x[i][j] + r.x[i][k]*r1.x[k][j]) % m
			}
		}
	}
	return res
}

func (r Matrix) powerMod(a uint64, b uint64) Matrix {
	matrix := newMatrix(2, 2)
	matrix.setValue(0, 0, 1)
	matrix.setValue(0, 1, 1)
	matrix.setValue(1, 0, 1)
	for a > 0 {
		if a%2 == 1 {
			matrix = matrix.multi(r, b)
		}
		r = r.multi(r, b)
		a /= 2
	}
	return matrix
}

func ok(u uint64, l uint64, r uint64, k uint64) bool {
	if (r/u - (l-1)/u) >= k {
		return true
	}
	return false
}

func main() {
	var m uint64
	var l uint64
	var r uint64
	var k uint64
	fmt.Scanf("%d%d%d%d", &m, &l, &r, &k)
	var found uint64
	for i := uint64(1); i*i <= r; i++ {
		if ok(i, l, r, k) {
			if i > found {
				found = i
			}
		}
		if ok(r/i, l, r, k) {
			if r/i > found {
				found = r / i
			}
		}
	}
	if found <= 2 {
		fmt.Println(1 % m)
		return
	}
	matrix := newMatrix(2, 2)
	matrix.setValue(0, 0, 1)
	matrix.setValue(0, 1, 1)
	matrix.setValue(1, 0, 1)
	matrix = matrix.powerMod(found-2, m)
	fmt.Println(matrix.x[0][0])
}


package main

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

func solve() {
	t := readInt()
	m := readInt()

	mem := make([]int, m)
	xid := 1

	for i := 0; i < t; i++ {
		op := readString()
		if op == "alloc" {
			id := readInt()
			cnt := 0
			idx := 0
			for i, v := range mem {
				if v == 0 {
					if cnt == 0 {
						idx = i
					}
					cnt++
					if cnt == id {
						break
					}
				} else {
					cnt = 0
				}
			}
			if cnt == id {
				for i := 0; i < id; i++ {
					mem[idx+i] = xid
				}
				fmt.Println(xid)
				xid++
			} else {
				fmt.Println("NULL")
			}
		} else if op == "erase" {
			found := false
			id := readInt()
			if id <= 0 {
				fmt.Println("ILLEGAL_ERASE_ARGUMENT")
				continue
			}

			for i, v := range mem {
				if v == id {
					found = true
					mem[i] = 0
				}
			}
			if !found {
				fmt.Println("ILLEGAL_ERASE_ARGUMENT")
			}
		} else if op == "defragment" {
			nmem := make([]int, m)
			n := 0
			for _, v := range mem {
				if v == 0 {
					continue
				}
				nmem[n] = v
				n++
			}
			mem = nmem
		} else {
			panic(op)
		}
	}
}

var scanner *bufio.Scanner

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

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

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

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

[{'input': '6 10\r\nalloc 5\r\nalloc 3\r\nerase 1\r\nalloc 6\r\ndefragment\r\nalloc 6\r\n', 'output': ['1\r\n2\r\nNULL\r\n3\r\n']}, {'input': '6 1\r\ndefragment\r\nalloc 10\r\nalloc 1\r\nerase -1\r\nerase 1\r\nerase 1\r\n', 'output': ['NULL\r\n1\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\n']}, {'input': '14 100\r\nalloc 99\r\nalloc 1\r\nalloc 1\r\nerase 2\r\nalloc 1\r\nerase 4\r\nerase 1\r\nalloc 100\r\nalloc 1\r\nalloc 99\r\ndefragment\r\nerase 4\r\nalloc 100\r\nalloc 99\r\n', 'output': ['1\r\n2\r\nNULL\r\n3\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\n4\r\nNULL\r\nNULL\r\nNULL\r\n']}, {'input': '26 25\r\ndefragment\r\nerase 1\r\nerase -1560200883\r\nalloc 44\r\ndefragment\r\nalloc 75\r\nalloc 22\r\ndefragment\r\nerase 4\r\ndefragment\r\nalloc 57\r\nalloc 53\r\nerase 4\r\nerase -1639632026\r\nerase -2121605039\r\nerase 3\r\nalloc 51\r\nalloc 65\r\ndefragment\r\nerase 2\r\nerase 4\r\nalloc 52\r\nerase 3\r\ndefragment\r\nerase -1842529282\r\nerase 3\r\n', 'output': ['ILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\n1\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\n']}, {'input': '22 9\r\nerase 1\r\nalloc 6\r\nalloc 65\r\nerase 1\r\nalloc 87\r\nerase -1638927047\r\nalloc 5\r\nerase 2\r\nalloc 70\r\ndefragment\r\nalloc 20\r\nalloc 48\r\nerase -69401977\r\nalloc 20\r\ndefragment\r\nerase 7\r\ndefragment\r\nerase 9\r\nerase 7\r\nerase 4\r\ndefragment\r\nalloc 66\r\n', 'output': ['ILLEGAL_ERASE_ARGUMENT\r\n1\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\n2\r\nNULL\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\n']}, {'input': '12 40\r\nerase 1\r\nalloc 21\r\nalloc 5\r\nalloc 7\r\ndefragment\r\ndefragment\r\nerase 2\r\nalloc 83\r\nerase 4\r\ndefragment\r\nalloc 59\r\ndefragment\r\n', 'output': ['ILLEGAL_ERASE_ARGUMENT\r\n1\r\n2\r\n3\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\n']}, {'input': '38 18\r\nalloc 72\r\nerase 2\r\nalloc 50\r\ndefragment\r\nerase 3\r\ndefragment\r\nalloc 43\r\nalloc 41\r\ndefragment\r\ndefragment\r\nalloc 26\r\nalloc 46\r\nalloc 16\r\nalloc 15\r\ndefragment\r\ndefragment\r\nalloc 95\r\nerase 7\r\nerase 7\r\nerase 5\r\nerase 2\r\nerase 9\r\nerase 7\r\nalloc 43\r\ndefragment\r\nerase 7\r\ndefragment\r\nalloc 48\r\nalloc 77\r\nerase 10\r\nerase 11\r\nalloc 16\r\nalloc 84\r\nerase 1\r\ndefragment\r\nalloc 86\r\ndefragment\r\nerase 13\r\n', 'output': ['NULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\nNULL\r\nNULL\r\n1\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\n']}, {'input': '37 74\r\nalloc 11\r\ndefragment\r\nerase 1\r\ndefragment\r\nerase 2\r\ndefragment\r\nalloc 90\r\nerase 3\r\nerase 2\r\nerase 3\r\nerase 1\r\nerase 1\r\nalloc 38\r\nalloc 19\r\nerase 1\r\nerase 3\r\ndefragment\r\nalloc 93\r\nerase 5\r\nerase 4\r\nalloc 66\r\nalloc 71\r\nerase 5\r\ndefragment\r\ndefragment\r\ndefragment\r\ndefragment\r\nerase 7\r\nalloc 47\r\nerase -95616683\r\nerase 2\r\nalloc 28\r\nalloc 32\r\nerase 11\r\nalloc 50\r\ndefragment\r\ndefragment\r\n', 'output': ['1\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\n2\r\n3\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\n4\r\n5\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\n']}, {'input': '16 49\r\nerase -751005193\r\ndefragment\r\nalloc 37\r\nalloc 82\r\nerase 3\r\nerase 1\r\nalloc 80\r\nalloc 51\r\ndefragment\r\nalloc 74\r\nerase 1\r\nalloc 91\r\ndefragment\r\ndefragment\r\nalloc 98\r\ndefragment\r\n', 'output': ['ILLEGAL_ERASE_ARGUMENT\r\n1\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\n']}, {'input': '42 98\r\ndefragment\r\ndefragment\r\ndefragment\r\ndefragment\r\ndefragment\r\nalloc 5\r\nalloc 66\r\ndefragment\r\nerase 3\r\nalloc 53\r\ndefragment\r\nerase 4\r\nerase 2\r\nalloc 70\r\nerase 3\r\ndefragment\r\ndefragment\r\nerase 2\r\nerase 3\r\nerase -1327931832\r\nalloc 93\r\nalloc 64\r\nerase 7\r\nerase 6\r\nerase 3\r\nalloc 61\r\nalloc 12\r\nalloc 65\r\nerase 2\r\nalloc 46\r\nerase 11\r\nerase 9\r\nerase 9\r\nerase 6\r\nalloc 2\r\nalloc 78\r\ndefragment\r\nerase 13\r\nerase 6\r\nerase 10\r\nalloc 53\r\nalloc 46\r\n', 'output': ['1\r\n2\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\n3\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\n4\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\n']}, {'input': '19 46\r\nalloc 21\r\nerase 2\r\nerase 1\r\ndefragment\r\nalloc 4\r\ndefragment\r\ndefragment\r\nalloc 40\r\nerase 1\r\ndefragment\r\ndefragment\r\nalloc 68\r\nerase -388966015\r\nalloc 85\r\nalloc 53\r\nerase 4\r\ndefragment\r\nalloc 49\r\nalloc 88\r\n', 'output': ['1\r\nILLEGAL_ERASE_ARGUMENT\r\n2\r\n3\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\n']}, {'input': '44 46\r\nalloc 28\r\nalloc 36\r\ndefragment\r\nerase -937404236\r\nalloc 71\r\ndefragment\r\nalloc 81\r\nalloc 51\r\nerase 3\r\ndefragment\r\nalloc 48\r\nerase 1\r\ndefragment\r\nalloc 36\r\ndefragment\r\ndefragment\r\nerase 1\r\ndefragment\r\ndefragment\r\nerase -1173350787\r\nalloc 94\r\nerase 5\r\ndefragment\r\nerase 9\r\nalloc 98\r\nerase 7\r\ndefragment\r\nerase 5\r\nerase 1\r\ndefragment\r\nerase 2\r\ndefragment\r\nerase 4\r\ndefragment\r\nerase 9\r\nalloc 8\r\ndefragment\r\nerase 9\r\ndefragment\r\ndefragment\r\ndefragment\r\nerase 1\r\nalloc 70\r\nerase 9\r\n', 'output': ['1\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nNULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\n2\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\n3\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\n']}, {'input': '26 25\r\nalloc 25\r\nerase 1\r\nalloc 24\r\nerase 2\r\nalloc 23\r\nerase 3\r\nalloc 24\r\nerase 4\r\nalloc 24\r\nerase 5\r\nalloc 21\r\nerase 6\r\nalloc 24\r\nerase 7\r\nalloc 25\r\nerase 8\r\nalloc 25\r\nerase 9\r\nalloc 24\r\nerase 10\r\nalloc 25\r\nerase 11\r\nalloc 25\r\nerase 12\r\nalloc 25\r\nerase 13\r\n', 'output': ['1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n']}, {'input': '22 9\r\nalloc 9\r\nerase 1\r\nalloc 9\r\nerase 2\r\nalloc 9\r\nerase 3\r\nalloc 9\r\nerase 4\r\nalloc 9\r\nerase 5\r\nalloc 9\r\nerase 6\r\nalloc 9\r\nerase 7\r\nalloc 9\r\nerase 8\r\nalloc 9\r\nerase 9\r\nalloc 9\r\nerase 10\r\nalloc 9\r\nerase 11\r\n', 'output': ['1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n']}, {'input': '7 6\r\nalloc 1\r\nalloc 2\r\nalloc 3\r\nerase 1\r\ndefragment\r\nerase 3\r\nalloc 4\r\n', 'output': ['1\r\n2\r\n3\r\n4\r\n']}, {'input': '3 1\r\nerase -1\r\nerase 0\r\nerase -2147483648\r\n', 'output': ['ILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\nILLEGAL_ERASE_ARGUMENT\r\n']}, {'input': '7 100\r\nalloc 100\r\nerase 2147483647\r\nerase 1\r\nalloc 50\r\nalloc 50\r\nerase 3\r\nerase -2147483648\r\n', 'output': ['1\r\nILLEGAL_ERASE_ARGUMENT\r\n2\r\n3\r\nILLEGAL_ERASE_ARGUMENT\r\n']}, {'input': '12 10\r\nalloc 6\r\nalloc 2\r\nerase 1\r\nalloc 4\r\nalloc 2\r\nerase 3\r\nalloc 2\r\nalloc 3\r\nalloc 1\r\nalloc 1\r\nalloc 1\r\nalloc 1\r\n', 'output': ['1\r\n2\r\n3\r\n4\r\n5\r\nNULL\r\n6\r\n7\r\n8\r\n9\r\n']}, {'input': '8 50\r\nalloc 51\r\ndefragment\r\nalloc 100\r\ndefragment\r\nerase 1\r\nalloc 50\r\ndefragment\r\nalloc 50\r\n', 'output': ['NULL\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\n1\r\nNULL\r\n']}, {'input': '10 10\r\nalloc 10\r\nerase -1\r\nerase 1\r\nalloc 5\r\nerase -1\r\nalloc 5\r\nerase 0\r\nalloc 5\r\nerase 0\r\nalloc 5\r\n', 'output': ['1\r\nILLEGAL_ERASE_ARGUMENT\r\n2\r\nILLEGAL_ERASE_ARGUMENT\r\n3\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\nNULL\r\n']}, {'input': '16 10\r\nalloc 10\r\ndefragment\r\ndefragment\r\ndefragment\r\nalloc 10\r\nerase 1\r\nerase 2\r\nalloc 6\r\ndefragment\r\ndefragment\r\nalloc 4\r\ndefragment\r\ndefragment\r\nerase 3\r\ndefragment\r\nalloc 6\r\n', 'output': ['1\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\n2\r\n3\r\nNULL\r\n']}, {'input': '16 10\r\nalloc 10\r\ndefragment\r\ndefragment\r\ndefragment\r\nalloc 10\r\nerase 1\r\nerase 2\r\nalloc 6\r\ndefragment\r\ndefragment\r\nalloc 4\r\ndefragment\r\ndefragment\r\nerase 2\r\ndefragment\r\nalloc 6\r\n', 'output': ['1\r\nNULL\r\nILLEGAL_ERASE_ARGUMENT\r\n2\r\n3\r\n4\r\n']}]


package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

var n, a, b int

var best = 999999
var ans []int

func getCount(health, damage int) int {
	if health%damage == 0 {
		return health / damage
	} else {
		return (health / damage) + 1
	}
}

func dfs(layer int, h []int, solution []int, slen int) {
	if slen >= best {
		return
	}

	if len(h) == 2 {
		ca, cb := getCount(h[0], a), getCount(h[1], b)
		if ca < cb {
			ca = cb
		}
		if slen+ca < best {
			best = slen + ca
			ans = make([]int, best)
			for i := 0; i < slen; i++ {
				ans[i] = solution[i]
			}
			for i := 0; i < ca; i++ {
				ans[slen+i] = layer + 1
			}
		}
		return
	}

	count0 := getCount(h[0], b)
	count1 := getCount(h[1], a)
	count2 := getCount(h[2], b)

	for i := count0; true; i++ {
		h0, h1, h2 := h[0], h[1], h[2]

		h[0] = 0
		if h1 >= a*i {
			h[1] = h1 - a*i
		} else {
			h[1] = 0
		}
		if h2 >= b*i {
			h[2] = h2 - b*i
		} else {
			h[2] = 0
		}
		for j := 0; j < i; j++ {
			solution[slen+j] = layer + 2
		}
		dfs(layer+1, h[1:], solution, slen+i)

		h[0], h[1], h[2] = h0, h1, h2
		if i > count0 && i > count1 && i > count2 {
			break
		}
	}
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	fmt.Fscanf(reader, "%d %d %d\n", &n, &a, &b)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d ", &h[i])
		h[i]++
	}
	dfs(0, h, make([]int, 128, 128), 0)
	fmt.Printf("%d\n", best)
	for i := 0; i < best; i++ {
		fmt.Printf("%d ", ans[i])
	}
}


package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

var n, m int
var vType []Type
var edges [][]int

func main() {
	defer out.Flush()
	fmt.Fscan(in, &n, &m)
	vType = make([]Type, n)
	edges = make([][]int, n)
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Fscan(in, &a, &b)
		a--
		b--
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
	}
	if solve() {
		fmt.Fprintln(out, "Yes")
		for v := range vType {
			fmt.Fprint(out, string('a'+vType[v]-1))
		}
		fmt.Fprintln(out)
	} else {
		fmt.Fprintln(out, "No")
	}
}

func solve() bool {
	for v := range edges {
		if len(edges[v]) == n-1 {
			vType[v] = B
		}
	}
	for v := range vType {
		if vType[v] == UNSEEN {
			mark(v, A)
			break
		}
	}
	for v := range vType {
		if vType[v] == UNSEEN {
			mark(v, C)
			break
		}
	}
	var a, b, c int
	for v := range vType {
		switch vType[v] {
		case UNSEEN:
			return false
		case A:
			a++
		case B:
			b++
		case C:
			c++
		}
	}
	for v := range vType {
		if vType[v] == A && len(edges[v]) != a-1+b {
			return false
		}
		if vType[v] == C && len(edges[v]) != c-1+b {
			return false
		}
	}
	return true
}

func mark(v int, t Type) {
	if vType[v] != UNSEEN {
		return
	}
	vType[v] = t
	for _, u := range edges[v] {
		mark(u, t)
	}
}

type Type int

const (
	UNSEEN Type = iota
	A
	B
	C
)


package main

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

const N = 500000

func IntMin(x, y int) int {
  if x < y {
    return x
  }
  return y
}

var v, stk [N]int

func main() {
  r := bufio.NewReader(os.Stdin)
  var n, top int = 0, 0
  var res int64 = 0
  fmt.Fscan(r, &n)
  for i := 0; i < n; i++ {
    fmt.Fscan(r, &v[i])
    for top >= 2 && stk[top-2] >= stk[top-1] && stk[top-1] <= v[i] {
      res += int64(IntMin(v[i], stk[top-2]))
      top--
    }
    stk[top] = v[i]
    top++
  }
  sort.Sort(sort.IntSlice(stk[:top]))
  for i := 0; i < top-2; i++ {
    res += int64(stk[i])
  }
  fmt.Println(res)
}


package main

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

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

	var n, k int
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &k)

	mp := make(map[int][]int)

	for i := 0; i < n; i++ {
		var x int
		fmt.Fscan(in, &x)

		cnt := 0
		for {
			// fmt.Println(x)
			mp[x] = append(mp[x], cnt)
			cnt++
			if x == 0 {
				break
			}
			x /= 2;
		}
	}
	bst := 2000000000
	for _, arr := range mp {
		if len(arr) < k {
			continue
		}

		sort.Slice(arr, func(i, j int) bool {
			return arr[i] < arr[j]
		})

		aux := 0
		for i, val := range arr {
			if i == k {
				break
			}
			aux += val
		}
		if aux < bst {
			bst = aux
		}

	}
	fmt.Println(bst)
}


let data = '';

const solve = () => {
    /**
     * Three rings to the elven-kings under the sky,
     * Seven for the dwarf-lords in their halls of stone,
     * Nine for mortal men doomed to die...
     */
    let mithrandir = 0;

    const [
        _,
        activeStateCost,
        screensaverCost,
        sleepStateCost,
        fromActiveToScreensaverDuration,
        fromScreensaverToSleepStateDuration,
        ...periods
    ] = data
        .trim()
        .split(/\n| /)
        .map(el => +el);

    const inactivePeriods = [];
    const activePeriods = [];

    activePeriods.push(periods[1] - periods[0]);

    for(let i=2; i<periods.length; i+=2) {
        activePeriods.push(periods[i+1] - periods[i]);
        inactivePeriods.push(periods[i] - periods[i-1]);
    }

    mithrandir += activePeriods.reduce((sum, val) => sum += val * activeStateCost, 0);
    mithrandir += inactivePeriods.reduce((holder, val) => {
        let sum = 0;
        if(val - fromActiveToScreensaverDuration > 0) {
            sum += fromActiveToScreensaverDuration * activeStateCost;
            val -= fromActiveToScreensaverDuration;

            if(val - fromScreensaverToSleepStateDuration > 0) {
                sum += fromScreensaverToSleepStateDuration * screensaverCost;
                val -= fromScreensaverToSleepStateDuration;

                if(val > 0) {
                    sum += val * sleepStateCost;
                }
            } else {
                sum += val * screensaverCost;
            }
        } else {
            sum += val * activeStateCost;
        }

        return sum + holder;
    }, 0);

    console.log(mithrandir);
}

process.stdin.on('data', c => data += c);
process.stdin.on('end', solve);


let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var k = lines[1].split(' ');
    var even = 0;
    var odd = 0;
    for(var j = 0; j < n; j++){
        if(k[j] % 2 === 0){
            even++;
        }else{
            odd++;
        }
    }
    if(odd % 2 == 1){
        console.log(odd);
    }else{
        console.log(even);
    }
});


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\nâå¥å âåºå');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException âThere is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray(N);
	var count = new Array(5001).fill(0);
	for(var i = 0; i < N; i++){
		count[list[i]]++;
	}
	var output = 0;
	for(var i = 1; i <= N; i++){
		if(count[i] == 0){
			output++;
		}
	}
	myout(output);
}


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
const students = [];
let n, m;

rl.on('line', (d) => {
  if (c === 0) {
    [n, m] = d.split(' ').map(Number);
    c++;
    return;
  }

  const marks = d;
  students.push(marks);
  c++;
});

rl.on('close', () => {
  const bests = new Set();
  for (let i = 0; i < students[0].length; i++) {
    let best = 0;
    for (let j = 0; j < students.length; j++) {
      if (students[j][i] > best) {
        best = students[j][i];
      }
    }

    for (let z = 0; z < students.length; z++) {
      if (students[z][i] === best) {
        bests.add(z);
      }
    }
  }

  console.log(bests.size);
});


let fs = require("fs");

let txt = fs
  .readFileSync(0, "utf-8")
  .split(/[\n\r]/)
  .filter((data) => data.length > 0);
let arr = txt[1]
  .split(" ")
  .map((d) => d.trim())
  .filter((d) => d.length > 0)
  .map((d) => Number(d));

let min = arr[1];
let max = arr[1];
let amazing = 0;
arr.forEach((data) => {
  if (data > max) {
    max = data;
    ++amazing;
  } else if (data < min) {
    min = data;
    ++amazing;
  }
});

console.log(amazing);


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\nâå¥å âåºå');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException âThere is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var N = nextInt();
	var list = new Array(N);
	for(var i = 0; i < N; i++){
		list[i] = new Array(N);
		for(var j = 0; j < N; j++){
			var v = nextInt();
			list[i][j] = {
				v : v,
				y : v,
				x : v
			};
		}
	}
	for(var i = 0; i < N; i++){
		for(var j = 1; j < N; j++){
			list[i][j].x += list[i][j - 1].x;
		}
		for(var j = N - 2; j >= 0; j--){
			list[i][j].x = list[i][j + 1].x;
		}
	}
	for(var i = 1; i < N; i++){
		for(var j = 0; j < N; j++){
			list[i][j].y += list[i - 1][j].y;
		}
	}
	for(var i = N - 2; i >= 0; i--){
		for(var j = 0; j < N; j++){
			list[i][j].y = list[i + 1][j].y;
		}
	}
	var count = 0;
	for(var i = 0; i < N; i++){
		for(var j = 0; j < N; j++){
			if(list[i][j].y > list[i][j].x){
				count++;
			}
		}
	}

	myout(count);
}


let input = "";
process.stdin.on("data", (data) => (input += data));
process.stdin.on("end", () => {
  let lines = input.split("\n");
  let n = lines.shift();
  let count = [0, 0, 0, 0, 0];
  lines
    .shift()
    .trim()
    .split(" ")
    .forEach((x) => count[x]++);
  let res = count[4];
  res += Math.floor(count[2] / 2);
  count[2] = count[2] % 2;
  let min13 = Math.min(count[1], count[3]);
  res += min13;
  count[1] -= min13;
  count[3] -= min13;
  if (count[2]) {
    count[1] -= Math.min(2, count[1]);
    res++;
  }
  res += Math.ceil(count[1] / 4);
  res += count[3];
  console.log(res);
});


const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

var calculateTrees = function (cont, startRow, endRow, startCol, endCol) {
    let ans = 0;
    for (let i = startRow; i < endRow; i++)
        for (let j = startCol; j < endCol; j++)
            ans += cont[i][j];

    //console.log(" startRow=%d  endRow=%d  startCol=%d  endCol=%d   ans=%d",startRow, endRow, startCol, endCol,ans);
    return ans;
}

var indicator = 0, N, M, temp, cont = [], HouseX, HouseY;
rl.on('line', (input) => {
    if (indicator == 0) {
        temp = input.split(" ").map(item => parseInt(item));
        N = temp[0];
        M = temp[1];
        indicator++;
    }
    else if (indicator <= N) {
        cont.push(input.split(" ").map(item => parseInt(item)));
        indicator++;
    }
    else {
        temp = input.split(" ").map(item => parseInt(item));
        HouseX = temp[0];
        HouseY = temp[1];
    }
}).on('close', () => {
    let ans = N * M, helper;
    for (let i = 0; i < N; i++) {
        for (let j = 0; j < M; j++) {
            if (i + HouseX <= N && j + HouseY <= M) {
                helper = calculateTrees(cont, i, i + HouseX, j, j + HouseY);
                if (ans > helper)
                    ans = helper;
            }
            if (i + HouseY <= N && j + HouseX <= M) {
                helper = calculateTrees(cont, i, i + HouseY, j, j + HouseX);
                if (ans > helper)
                    ans = helper;
            }
        }
    }
    console.log(ans);
});


let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var k = lines[1].split(' ').map(Number).sort(function(a, b){return a - b});
    var a = [];
    for(var j = 1; j <= n; j++){
        if(k[j] != k[j - 1]){
            a.push(k[j - 1]);
        }
    }
    if(a[1] === undefined){
        console.log('NO');
    }else{
        console.log(a[1]);
    }
});


'use strict';

function solve(n, m, a) {
  const h = new Array(m).fill(0);
  let res = 0;
  for (let i = 0; i < n; i++) {
    for (let j = 0; j < m; j++) {
      if (a[i][j]) h[j] = 0;else h[j]++;
    }
    const stack = [];
    for (let j = 0; j <= m; j++) {
      while (stack.length && (j === m || h[stack[stack.length - 1]] > h[j])) {
        var _stack;
        const cur = stack.pop(),
              p = (_stack = stack[stack.length - 1]) !== null && _stack !== void 0 ? _stack : -1;
        if (h[cur]) res = Math.max(res, (j - p - 1) * 2 + h[cur] * 2);
      }
      stack.push(j);
    }
  }
  return res;
}

async function main(r) {
  const rns = async () => {
    return (await r()).split(' ').filter(s => s !== '').map(Number);
  };
  try {
    let t = 1;
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const [n, m] = await rns();
      const a = [];
      let tmp = n;
      while (tmp--) {
        a.push((await r()).split('').map(Number));
      }
      res[i] = solve(n, m, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});


const readline = require('readline');
const { stdin: input, stdout: output } = require('process');
const rl = readline.createInterface({ input, output });

function findMaxFrom(arr, from){
    let ans = arr[from];
    for(let i = from + 1 ; i < arr.length ; i++ ){
        if(ans < arr[i])
        ans = arr[i];
    }
    return ans;

}

let N = -1, arr = [], rubles = 0, ans = 0;

rl.on('line', (input) => {
    if (N === -1) {
        arr = input.split(' ').map(it => parseInt(it));
        N = arr[0];
        rubles = arr[1];
        ans = rubles;
    }
    else {
        arr = input.split(' ').map(it => parseInt(it));

        for (let i = 0; i < N - 1; i++) {
            let dollars = parseInt(rubles / arr[i]);
            let rem = rubles % arr[i];
            let maxCurr = Math.max(...arr.slice(i + 1));
          // let maxCurr = findMaxFrom(arr, i + 1)
            let newRub = dollars * maxCurr + rem;

            if (newRub > ans)
                ans = newRub;
        }

        console.log(ans);
        rl.close();
    }
})

/*

n = 2  rubl = 4
3 7

I. 4 rubl -> 1$ (1 rubl)
II. 1$ -> 7 rubl + 1 rubl

-----------------------------------

n = 4 rubl = 10
4 2 3 1

I. 10 rubl -> 10 / 4 = 2$ (2 rubl)
II. 2$ -> 2 * 2 = 4rubl
III. 2$ -> 2 * 3 = 6rubl
IV. 2$ -> 2 * 1 = 2 rubl

II. 10 rubl -> 10 / 2 = 5$
III. 5$ -> 5 * 3 = 15 rubl

*/


const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var calculateTrees = (cont, startRow, endRow, startCloumn, endColumn) => {
    let ans = 0;
    for (let i = startRow; i < endRow; i++)
        for (let j = startCloumn; j < endColumn; j++)
            if (cont[i][j] == 1)
                ans += cont[i][j];
    return ans;
}
var N, M, cont = [], houseX, houseY, indicator = 0, temp = [];
rl.on('line', (input) => {
    if (indicator == 0) {
        temp = input.split(' ').map(item => parseInt(item));
        N = temp[0], M = temp[1];
        indicator++;
    } else if (indicator <= N) {
        cont.push(input.split(' ').map(item => parseInt(item)));
        indicator++;
    } else {
        temp = input.split(' ').map(item => parseInt(item));
        houseX = temp[0], houseY = temp[1];
    }
}).on("close", () => {
    let ans = N * M, helper;
    for (let i = 0; i < N; i++) {
        for (let j = 0; j < M; j++) {
            if (i + houseX <= N && j + houseY <= M) {
                helper = calculateTrees(cont, i, i + houseX, j, j + houseY);
                if (ans > helper)
                    ans = helper;
            }
            if (i + houseY <= N && j + houseX <= M) {
                helper = calculateTrees(cont, i, i + houseY, j, j + houseX);
                if (ans > helper)
                    ans = helper;
            }
        }
    }
    console.log(ans);
});


const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
let i = 0;
let orginal = [];
let swapped = [];
readline.on('line', line => {
  i++;
  if (i === 1) {
    orginal = Array.from({length: parseInt(line) + 1}, (x, k) => k);
    orginal.splice(0, 1);
  }
  else {
    readline.close();
    swapped = line.split(' ').map((x) => {
      return parseInt(x);
    });
    difference = orginal.reduce((list, coin, index) => {
      if (coin !== swapped[index]) {
        list.push(coin)
      }
      return list
    }, []);
    if (difference.length === 0) {
      console.log(0, 0)
    } else {
      const firstIndex = orginal.indexOf(difference[0]);
      const lastIndex = orginal.indexOf(difference[difference.length - 1]);
      const originalPart = orginal.slice(firstIndex, lastIndex + 1)
      const reversedPart = swapped.slice(firstIndex, lastIndex + 1);
      if (isEqual(originalPart, reversedPart.reverse())) {
        console.log(difference[0], difference[difference.length - 1])
      } else {
        console.log(0, 0)
      }
    }

  }
});

function isEqual(a, b)
{
  // if length is not equal
  if(a.length!=b.length)
   return false;
  else
  {
  // comapring each element of array
    return a.reduce((value, e, index) => {
      if (e === b[index]) {
        value = true
        return value
      }
      value = false
      return value
    }, false)
  }
}


const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
let isFirstLine = true;
let number;
let maxRank;
let soldiers;
let coin = 0;
readline.on('line', line => {
  if (isFirstLine) {
    let firstLine = line.split(' ').map(x => parseInt(x));
    number = firstLine[0];
    maxRank = firstLine[1]
    isFirstLine = false;
  } else {
    soldiers = line.split(' ').map(x => parseInt(x));
    readline.close();
    while (soldiers.some(s => s < maxRank)) {
      coin++
      let currentSoldeir = 0;
      for (let i = 0; i < soldiers.length; i++) {
        const soldeir = soldiers[i];
        if (soldeir == maxRank) break
        if (currentSoldeir < soldeir) {
          soldiers[i]++
          currentSoldeir = soldeir;
        }
      soldiers = soldiers.sort((a, b) => a - b)
      }
    }
    console.log(coin);
  }
})


// author: Oscar Ramos

/// Source Code
// const input = require('competitive-programming-js').inputReader
// const { forn, vector, range } = require('../utils/utils')
//
// const n = input.readNumber()
//
// const coords = []
// forn(n, () => {
//   const [x, y] = input.readNumberArray()
//   coords.push([x, y])
// })
//
// const visited = vector(n, false)
//
// let ans = -1
//
// const dfs = i => {
//   if (!visited[i]) {
//     visited[i] = true
//     forn(n, (j => {
//       if (coords[i][0] === coords[j][0] ||
//         coords[i][1] === coords[j][1]) {
//         dfs(j)
//       }
//     }))
//   }
// }
//
// forn(n, i => {
//   if (!visited[i]) {
//     ans += 1
//   }
//   dfs(i)
// })
//
// console.log(ans)
//

!function(n){var t={};function r(e){if(t[e])return t[e].exports;var o=t[e]={i:e,l:!1,exports:{}};return n[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=n,r.c=t,r.d=function(n,t,e){r.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:e})},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,t){if(1&t&&(n=r(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var o in n)r.d(e,o,function(t){return n[t]}.bind(null,o));return e},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,"a",t),t},r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.p="",r(r.s=1)}([function(n,t){n.exports=function(n){return null!=n&&"object"==typeof n&&!0===n["@@functional/placeholder"]}},function(n,t,r){n.exports=r(2)},function(n,t,r){let e,o=0,u={readNumber:function(){return Number(e[o++])},readNumberArray:function(){return e[o++].split(" ").map(n=>Number(n))}};var c="";process.stdin.resume(),process.stdin.setEncoding("utf8"),process.stdin.on("data",(function(n){c+=n})).on("end",(function(){e=c.trim().split("\n").map(n=>n.trim());const{forn:n,vector:t,range:o}=r(3),i=u.readNumber(),f=[];n(i,()=>{const[n,t]=u.readNumberArray();f.push([n,t])});const a=t(i,!1);let s=-1;const p=t=>{a[t]||(a[t]=!0,n(i,n=>{f[t][0]!==f[n][0]&&f[t][1]!==f[n][1]||p(n)}))};n(i,n=>{a[n]||(s+=1),p(n)}),console.log(s)}))},function(n,t,r){const e=r(4);n.exports={forn:(n,t)=>e(0,n).map(n=>t(n)),fornm:(n,t,r)=>e(0,n).map(n=>e(0,t).map(t=>r(n,t))),matrix:(n,t,r)=>e(0,n).map(()=>e(0,t).map(()=>r)),vector:(n,t)=>e(0,n).map(()=>t),range:e}},function(n,t,r){var e=r(5),o=r(7),u=e((function(n,t){if(!o(n)||!o(t))throw new TypeError("Both arguments to range must be numbers");for(var r=[],e=n;e<t;)r.push(e),e+=1;return r}));n.exports=u},function(n,t,r){var e=r(6),o=r(0);n.exports=function(n){return function t(r,u){switch(arguments.length){case 0:return t;case 1:return o(r)?t:e((function(t){return n(r,t)}));default:return o(r)&&o(u)?t:o(r)?e((function(t){return n(t,u)})):o(u)?e((function(t){return n(r,t)})):n(r,u)}}}},function(n,t,r){var e=r(0);n.exports=function(n){return function t(r){return 0===arguments.length||e(r)?t:n.apply(this,arguments)}}},function(n,t){n.exports=function(n){return"[object Number]"===Object.prototype.toString.call(n)}}]);

/// package.json
// {
//   "name": "competitive",
//   "version": "1.0.0",
//   "description": "",
//   "main": "src/index.js",
//   "scripts": {
//     "convert": "cp-convert -s src/index.js -d output/converted.js",
//     "bundle": "webpack --config ./webpack.config.js",
//     "test": "npm run convert && jest ./",
//     "production": "npm run convert && npm run bundle && node src/getOutput.js",
//     "start": "node src/index.js"
//   },
//   "author": "Oscar Ramos",
//   "dependencies": {
//     "child-process-promise": "^2.2.1",
//     "competitive-programming-js": "^1.0.10",
//     "mathball": "^0.4.0",
//     "ramda": "^0.27.1"
//   },
//   "devDependencies": {
//     "@types/jest": "^26.0.10",
//     "concat-stream": "^2.0.0",
//     "cross-spawn": "^7.0.3",
//     "jest": "^26.4.2",
//     "jest-expect-message": "^1.0.2",
//     "mock-stdin": "^1.0.0",
//     "terser-webpack-plugin": "^4.1.0",
//     "webpack": "^4.44.1",
//     "webpack-cli": "^3.3.12"
//   },
//   "jest": {
//     "setupFilesAfterEnv": ["jest-expect-message"]
//   }
// }
//


const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = 1//+lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[l++].trim().split(' ').map(Number)
        const edges = lines.slice(l, l + m).map(str => str.trim().split(' ').map(Number))
        l += m
        output[i] = solve(n, edges)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, edges) {
    const adj = {}
    for (let u = 1; u <= n; u++) {
        adj[u] = {}
    }
    edges.forEach(([a, b]) => {
        adj[a][b] = 1
        adj[b][a] = 1
    })

    const gs = Array(n + 1)
    const vs = []
    let g = 1
    for (let u = 1; u <= n; u++) {
        if (gs[u]) continue
        if (g > 3) return -1
        const temp = [u]
        gs[u] = g
        for (let v = u + 1; v <= n; v++) {
            if (!adj[u][v] && !gs[v]) {
                gs[v] = g
                temp.push(v)
            }
        }
        vs.push(temp)
        g++
    }
// console.log(gs, vs)
    if (vs.length < 3) return -1
    for (let i = 0; i < vs.length; i++) {
        for (let a = 0; a < vs[i].length; a++) {
            const u = vs[i][a]
            for (let j = i + 1; j < vs.length; j++) {
                for (let b = 0; b < vs[j].length; b++) {
                    const v = vs[j][b]
                    if (!adj[u][v]) return -1
                }
            }
        }
    }
    for (let [u, v] of edges) {
        if (gs[u] === gs[v]) return -1
    }
    gs.shift()
    return gs.join(' ')
}


process.stdin.resume()
process.stdin.setEncoding('utf-8')

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main(arr)
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt(a, i) {
  if(i === undefined) return parseInt(a.shift())
  else return parseInt(a[i])
}

function readInts(a, i) {
  if(i === undefined) return arr.shift().split(' ').map(a => parseInt(a))
  else return arr[i].split(' ').map(a => parseInt(a))
}

function main(input) {
  const [n, m] = readInts(input, 0)

  const arrays = new Array(n)
  for(let i = 0; i < n; i++) {
    arrays[i] = readInts(input, i + 1)
  }
  // wr(arrays)

  let l = 0
  let r = 10 ** 9
  let arr1, arr2
  arr1 = arr2 = -1
  while(r - l >= 2) {
    let m = Math.floor((l + r) / 2)
    if(can(m)) l = m
    else r = m
  }
  can(l)
  can(r)

  wr(arr1 + 1, arr2 + 1)
  function can(x) {
    const m21 = 1 << m
    const masks = new Array(m21).fill(-1)

    for(let i = 0; i < n; i++) {
      let msk = 0
      for(let j = 0; j < m; j++) {
        if(arrays[i][j] >= x) msk ^= (1 << j)
      }
      masks[msk] = i
    }

    if(masks[m21 - 1] != -1) {
      arr1 = masks[m21 - 1]
      arr2 = masks[m21 - 1]
      return true
    }

    for(let i = 0; i < m21; i++) {
      for(let j = 0; j < m21; j++) {
        if(masks[i] != -1 && masks[j] != -1 && (i | j) == m21 - 1){
          arr1 = masks[i]
          arr2 = masks[j]
          return true
        }
      }
    }

    return false
  }
}


const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split(/[\n\r]+/);
const log = (...args) => console.log(...args);

let count = 0;
const readnum = () => input[count++].trim().split(' ').map(a => +a);
const readword = () => input[count++].trim().split(' ');

  let [n,t] = readnum();
  console.log(solve(n,t));

function solve(n,t) {
  let dp = [...Array(25)].map(() =>
    [...Array(5)].map(() =>
      Array(25).fill(0)
    )
  );

    for(let i=1;i<=3;i++) dp[1][i][0]=1;
    for(let x=2;x<22;x++)
    for(let y=1;y<=4;y++)
    for(let t=0;t<21;t++)
    for(let h=1;h<=4;h++){
      if(x==2){
              if(y>h){
              if(t%2) dp[2][y][t+1]+=dp[1][h][t];
              else dp[2][y][t]+=dp[1][h][t];
            }
          }
          else{
              if(t%2){
              if(h>y) dp[x][y][t]+=dp[x-1][h][t];
              else if(h<y) dp[x][y][t+1]+=dp[x-1][h][t];
              }
              else{
              if(h<y) dp[x][y][t]+=dp[x-1][h][t];
              else if(h>y) dp[x][y][t+1]+=dp[x-1][h][t];
              }
          }
    }

    if(t*2+1>n||n>6*t+1) return 0;
    let ans=0;
    for(let i=1;i<=4;i++)
    ans+=dp[n][i][2*t-1];
    return ans;
}


'use strict';

function solve(n, m, s) {
  const diff = new Array(n + 2).fill(0);
  for (let str of s) {
    const num = Number(str.slice(1));
    if (str[0] === '+') {
      diff[num]++;
      diff[num + 1]--;
    } else {
      diff[0]++;
      diff[num]--;
      diff[num + 1]++;
      diff[n + 1]--;
    }
  }
  const suspects = new Set();
  let sum = diff[0];
  for (let i = 1; i <= n; i++) {
    sum += diff[i];
    if (sum === m) suspects.add(i);
  }
  const res = new Array(n);
  for (let i = 0; i < n; i++) {
    const str = s[i];
    const num = Number(str.slice(1));
    if (str[0] === '+') {
      if (suspects.has(num)) {
        if (suspects.size === 1) res[i] = 'Truth';else res[i] = 'Not defined';
      } else {
        res[i] = 'Lie';
      }
    } else {
      if (suspects.has(num)) {
        if (suspects.size === 1) res[i] = 'Lie';else res[i] = 'Not defined';
      } else {
        res[i] = 'Truth';
      }
    }
  }
  return res.join('\n');
}

async function main(read) {
  try {
    let res = [];
    let t = 1;
    while (t--) {
      const [n, m] = (await read()).split(' ').map(Number);
      const a = [];
      let tmp = n;
      while (tmp--) {
        a.push(await read());
      }
      res.push(solve(n, m, a));
    }
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', () => {
  inputs = str.split('\n').values();
  main(read);
});

[{'input': ['1 1\r\n+1\r\n'], 'output': ['Truth\r\n']}, {'input': ['3 2\r\n-1\r\n-2\r\n-3\r\n'], 'output': ['Not defined\r\nNot defined\r\nNot defined\r\n']}, {'input': ['4 1\r\n+2\r\n-3\r\n+4\r\n-1\r\n'], 'output': ['Lie\r\nNot defined\r\nLie\r\nNot defined\r\n']}, {'input': ['1 0\r\n-1\r\n'], 'output': ['Lie\r\n']}, {'input': ['2 2\r\n+1\r\n+1\r\n'], 'output': ['Truth\r\nTruth\r\n']}, {'input': ['2 1\r\n+2\r\n+1\r\n'], 'output': ['Not defined\r\nNot defined\r\n']}, {'input': ['2 0\r\n-2\r\n-2\r\n'], 'output': ['Lie\r\nLie\r\n']}, {'input': ['3 1\r\n+2\r\n+3\r\n+3\r\n'], 'output': ['Truth\r\nLie\r\nLie\r\n']}, {'input': ['6 3\r\n+5\r\n+5\r\n+5\r\n+1\r\n+1\r\n+1\r\n'], 'output': ['Not defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\n']}, {'input': ['4 3\r\n-4\r\n-3\r\n-1\r\n-3\r\n'], 'output': ['Not defined\r\nTruth\r\nNot defined\r\nTruth\r\n']}, {'input': ['10 4\r\n-8\r\n+1\r\n-6\r\n-10\r\n+5\r\n-6\r\n-8\r\n-8\r\n-4\r\n-8\r\n'], 'output': ['Lie\r\nLie\r\nTruth\r\nTruth\r\nLie\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': ['10 5\r\n-4\r\n+4\r\n+4\r\n-9\r\n-9\r\n-4\r\n-4\r\n+2\r\n-9\r\n-4\r\n'], 'output': ['Lie\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': ['7 2\r\n+5\r\n+5\r\n+5\r\n-2\r\n+1\r\n-5\r\n-6\r\n'], 'output': ['Lie\r\nLie\r\nLie\r\nNot defined\r\nLie\r\nTruth\r\nNot defined\r\n']}, {'input': ['7 4\r\n+7\r\n-3\r\n-3\r\n-4\r\n+3\r\n+3\r\n+3\r\n'], 'output': ['Not defined\r\nNot defined\r\nNot defined\r\nTruth\r\nNot defined\r\nNot defined\r\nNot defined\r\n']}, {'input': ['6 3\r\n-6\r\n-1\r\n+5\r\n+1\r\n+6\r\n+1\r\n'], 'output': ['Truth\r\nNot defined\r\nNot defined\r\nNot defined\r\nLie\r\nNot defined\r\n']}, {'input': ['5 3\r\n-2\r\n+2\r\n+2\r\n-3\r\n+5\r\n'], 'output': ['Not defined\r\nNot defined\r\nNot defined\r\nTruth\r\nNot defined\r\n']}, {'input': ['3 0\r\n-2\r\n-2\r\n-2\r\n'], 'output': ['Lie\r\nLie\r\nLie\r\n']}, {'input': ['5 3\r\n-1\r\n-1\r\n-4\r\n+1\r\n-4\r\n'], 'output': ['Lie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\n']}, {'input': ['9 6\r\n+2\r\n+7\r\n+7\r\n-1\r\n-4\r\n+7\r\n-7\r\n+7\r\n+5\r\n'], 'output': ['Lie\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': ['43 18\r\n-14\r\n-28\r\n+16\r\n+10\r\n+25\r\n-30\r\n+25\r\n+30\r\n+25\r\n+25\r\n+25\r\n+25\r\n-25\r\n+22\r\n+3\r\n-17\r\n+16\r\n-25\r\n+10\r\n+14\r\n+41\r\n+25\r\n-25\r\n+33\r\n+24\r\n-23\r\n-25\r\n+25\r\n-22\r\n+29\r\n+28\r\n-25\r\n-25\r\n-29\r\n+11\r\n+26\r\n-25\r\n+25\r\n+10\r\n+1\r\n-20\r\n-17\r\n+23\r\n'], 'output': ['Truth\r\nTruth\r\nNot defined\r\nLie\r\nNot defined\r\nTruth\r\nNot defined\r\nLie\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nLie\r\nLie\r\nTruth\r\nNot defined\r\nNot defined\r\nLie\r\nLie\r\nLie\r\nNot defined\r\nNot defined\r\nLie\r\nLie\r\nTruth\r\nNot defined\r\nNot defined\r\nTruth\r\nLie\r\nLie\r\nNot defined\r\nNot defined\r\nTruth\r\nLie\r\nLie\r\nNot defined\r\nNot defined\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nLie\r\n']}, {'input': ['28 12\r\n+10\r\n-7\r\n+17\r\n-20\r\n+7\r\n-7\r\n+13\r\n-21\r\n-7\r\n-7\r\n-18\r\n+7\r\n+7\r\n+3\r\n+6\r\n+14\r\n+7\r\n-24\r\n-21\r\n-7\r\n-7\r\n+4\r\n+7\r\n-7\r\n+21\r\n-7\r\n-26\r\n+7\r\n'], 'output': ['Lie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\n']}, {'input': ['17 9\r\n-6\r\n+16\r\n+5\r\n+16\r\n-17\r\n+17\r\n-11\r\n+5\r\n+14\r\n+5\r\n-8\r\n-5\r\n+6\r\n-2\r\n-11\r\n+4\r\n+17\r\n'], 'output': ['Truth\r\nNot defined\r\nNot defined\r\nNot defined\r\nTruth\r\nLie\r\nTruth\r\nNot defined\r\nLie\r\nNot defined\r\nTruth\r\nNot defined\r\nLie\r\nTruth\r\nTruth\r\nLie\r\nLie\r\n']}, {'input': ['14 3\r\n+14\r\n+12\r\n-9\r\n+9\r\n-9\r\n-9\r\n+8\r\n+9\r\n+2\r\n+1\r\n-13\r\n-9\r\n+13\r\n+3\r\n'], 'output': ['Lie\r\nLie\r\nLie\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nLie\r\nLie\r\nLie\r\n']}, {'input': ['10 4\r\n-9\r\n-8\r\n-5\r\n-9\r\n-7\r\n-9\r\n-9\r\n-9\r\n-4\r\n-9\r\n'], 'output': ['Lie\r\nTruth\r\nTruth\r\nLie\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': ['10 5\r\n-10\r\n-10\r\n-10\r\n-5\r\n-1\r\n+10\r\n-3\r\n-10\r\n-9\r\n-10\r\n'], 'output': ['Lie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': ['10 4\r\n-3\r\n-3\r\n-3\r\n-3\r\n-3\r\n-2\r\n-2\r\n-6\r\n-7\r\n-3\r\n'], 'output': ['Lie\r\nLie\r\nLie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\n']}, {'input': ['10 6\r\n-9\r\n-7\r\n-5\r\n-5\r\n-4\r\n-2\r\n-8\r\n-5\r\n-5\r\n-9\r\n'], 'output': ['Truth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\n']}, {'input': ['10 4\r\n-8\r\n-2\r\n-8\r\n+1\r\n-4\r\n-8\r\n-2\r\n-8\r\n-8\r\n-1\r\n'], 'output': ['Lie\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nLie\r\nTruth\r\nLie\r\nLie\r\nTruth\r\n']}, {'input': ['10 2\r\n-8\r\n+10\r\n+1\r\n+8\r\n+4\r\n+8\r\n+6\r\n-8\r\n+10\r\n+1\r\n'], 'output': ['Not defined\r\nLie\r\nLie\r\nNot defined\r\nLie\r\nNot defined\r\nLie\r\nNot defined\r\nLie\r\nLie\r\n']}, {'input': ['10 3\r\n+9\r\n+3\r\n+8\r\n+3\r\n+6\r\n-3\r\n+6\r\n+8\r\n+3\r\n+7\r\n'], 'output': ['Lie\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nLie\r\n']}, {'input': ['10 8\r\n-2\r\n+9\r\n+9\r\n-4\r\n+9\r\n+9\r\n+4\r\n-9\r\n-3\r\n+9\r\n'], 'output': ['Truth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nTruth\r\n']}, {'input': ['10 7\r\n-4\r\n+6\r\n+4\r\n+9\r\n+6\r\n+6\r\n+6\r\n+6\r\n+6\r\n+2\r\n'], 'output': ['Truth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\n']}, {'input': ['10 4\r\n+3\r\n+5\r\n+6\r\n+10\r\n+5\r\n+5\r\n+6\r\n+8\r\n+5\r\n+6\r\n'], 'output': ['Lie\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': ['10 7\r\n-6\r\n-10\r\n-3\r\n-1\r\n-3\r\n-7\r\n-2\r\n-7\r\n-7\r\n-3\r\n'], 'output': ['Truth\r\nTruth\r\nNot defined\r\nTruth\r\nNot defined\r\nNot defined\r\nTruth\r\nNot defined\r\nNot defined\r\nNot defined\r\n']}, {'input': ['10 5\r\n-4\r\n-4\r\n-1\r\n-5\r\n-7\r\n-4\r\n-4\r\n-4\r\n-1\r\n-7\r\n'], 'output': ['Lie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\n']}, {'input': ['10 5\r\n-9\r\n-7\r\n-6\r\n-3\r\n-10\r\n-10\r\n-10\r\n-10\r\n-10\r\n-2\r\n'], 'output': ['Truth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\nLie\r\nLie\r\nTruth\r\n']}, {'input': ['10 3\r\n-10\r\n-10\r\n-10\r\n-3\r\n-10\r\n-10\r\n-10\r\n-8\r\n-4\r\n-10\r\n'], 'output': ['Lie\r\nLie\r\nLie\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nLie\r\n']}, {'input': ['10 5\r\n-8\r\n-8\r\n-4\r\n-9\r\n-10\r\n-2\r\n-9\r\n-8\r\n-8\r\n-8\r\n'], 'output': ['Lie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\n']}, {'input': ['10 5\r\n+7\r\n+8\r\n+9\r\n+1\r\n+7\r\n+7\r\n+7\r\n+6\r\n+6\r\n+7\r\n'], 'output': ['Truth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\n']}, {'input': ['10 5\r\n+2\r\n+2\r\n+2\r\n+2\r\n+9\r\n+10\r\n+8\r\n+7\r\n+4\r\n+2\r\n'], 'output': ['Truth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\nLie\r\nLie\r\nTruth\r\n']}, {'input': ['10 9\r\n+7\r\n+7\r\n+7\r\n+7\r\n+7\r\n+7\r\n+5\r\n+7\r\n+7\r\n+7\r\n'], 'output': ['Truth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\n']}, {'input': ['10 3\r\n+10\r\n+2\r\n+10\r\n+9\r\n+1\r\n+9\r\n+4\r\n+9\r\n+3\r\n+2\r\n'], 'output': ['Lie\r\nLie\r\nLie\r\nTruth\r\nLie\r\nTruth\r\nLie\r\nTruth\r\nLie\r\nLie\r\n']}, {'input': ['10 6\r\n+10\r\n+10\r\n+10\r\n+3\r\n+10\r\n+10\r\n+6\r\n+6\r\n+10\r\n+8\r\n'], 'output': ['Truth\r\nTruth\r\nTruth\r\nLie\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': ['3 2\r\n-1\r\n+2\r\n+3\r\n'], 'output': ['Truth\r\nNot defined\r\nNot defined\r\n']}]


var readline = require('readline')
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
})
var inputs = []

const fn = debounce(function () {
  var n = +inputs[0];
  var monsters = inputs.slice(1, n + 1).map(function (str) {
    return str.split(' ').map(function (x) {
      return BigInt(x);
    });
  });
  var t = +inputs[n + 1];
  var p = inputs[n + 2].split(' ').map(function (x) {
    return BigInt(x);
  });
  p.push(BigInt(1e13));
  monsters.sort(function (a, b) {
    return Number(a[1] - b[1]);
  });
  var i = 0,
    j = 0,
    sum = 0n,
    ans = 0n,
    pre = 0n,
    factor = 1n;
  for (; i < n; i++) {
    var _a = monsters[i],
      cnt = _a[0],
      score = _a[1];
    sum += cnt;
    while (sum > p[j] && j < t) {
      ans += BigInt(p[j] - pre) * score * factor;
      // console.log(ans, p[j], pre, score, factor)
      pre = p[j];
      j++;
      factor++;
    }
    if (sum <= p[j]) {
      ans += BigInt(sum - pre) * score * factor;
      // console.log(ans, p[j], pre, score, factor)
      pre = sum;
    }
  }
  write(ans + '');
})
rl.on('line', function (line) {
  inputs.push(line.trim());
  fn()
})

function debounce(cb, delay) {
  if (delay === void 0) {
    delay = 100;
  }
  var timer = -1;
  return function () {
    if (timer !== -1) {
      clearTimeout(timer);
    }
    timer = setTimeout(function () {
      cb();
      timer = -1;
    }, delay);
  };
}

function write(x) {
  console.log(x)
}


'use strict';

function solve(n, a) {
  let x = 1,
      y = 1;
  for (let s of a) {
    if (s === 'UR' || s === 'DL') y++;else if (s === 'UL' || s === 'DR') x++;else if (s === 'ULDR') x++, y++;
  }
  return x * y;
}

async function main(read) {
  try {
    let t = 1;
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = [];
      let tmp = n;
      while (tmp--) {
        a.push(await read());
      }
      res[i] = solve(n, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.on('line', (line) => {
  const [n, d, m, l] = line.split(' ').map(Number);
  let platforms = [];
  for (let i = 0; i < n; i++) {
    platforms.push([(i * m), ((i * m) + l)]);
  }
  let coordinate = 0;
  while (true) {
    coordinate += d;
    let onPlatform = false;
    for (let i = 0; i < n; i++) {
      if (coordinate >= platforms[i][0] && coordinate <= platforms[i][1]) {
        onPlatform = true;
        break;
      }
    }
    if (!onPlatform) {
      console.log(coordinate);
      break;
    }
  }
});


function cutArea(h, w) {
    let min = Math.min(h, w);
    let max = Math.max(h, w);
    let power = Math.floor(Math.log2(min));
    let minCut = Math.pow(2, power);
    let maxCut = Math.min(max, Math.floor(minCut * 1.25));
    if (maxCut / minCut < 0.8) {
        minCut = Math.floor(maxCut / 1.25);
    }
    return [maxCut, minCut].sort((a, b) => b - a).join(' ');
}

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let input = [];
rl.on('line', function (line) {
    input.push(line);
}).on('close', function () {
    const [h, w] = input[0].split(' ').map(Number);
    console.log(cutArea(h, w));
    process.exit();
});


const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

const getMinTime = (a, v, l, d, w) => {
    let t1, t2, t3, t4, t5, t6, t7, t8, t9;
    let v1 = Math.sqrt(2 * a * d);
    let v2 = Math.sqrt(2 * a * (l - d));
    if (v < w) {
        if (v < v1 && v < v2) {
            t1 = v / a;
            t2 = (l - a * t1 * t1 / 2) / v;
            return t1 + t2;
        } else if (v1 < v2) {
            t1 = v1 / a;
            t2 = (l - a * t1 * t1 / 2) / v1;
            return t1 + t2;
        } else {
            t1 = v2 / a;
            t2 = (l - a * t1 * t1 / 2) / v2;
            return t1 + t2;
        }
    } else {
        if (v1 < w) {
            t1 = v1 / a;
            t2 = (l - a * t1 * t1 / 2) / v1;
            return t1 + t2;
        } else {
            t1 = w / a;
            t2 = (d - a * t1 * t1 / 2) / w;
            if (v2 < v) {
                t3 = v2 / a;
                t4 = (l - d - a * t3 * t3 / 2) / v2;
                return t1 + t2 + t3 + t4;
            } else {
                t3 = (v * v - w * w) / (2 * a);
                t4 = (l - d - t3) / v;
                return t1 + t2 + t3 / v + t4;
            }
        }
    }
}

rl.on('line', (line) => {
    let [a, v] = line.split(' ').map(Number);
    let [l, d, w] = line.split(' ').map(Number);
    console.log(getMinTime(a, v, l, d, w).toFixed(5));
});


'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const ils = ipt.split(EOL).slice(0, -1)
  ils[0] = '1000'

  const rr = []

  for (let i = 1; i < ils.length; i++) {
    const p = ils[i - 1]
    const c = ils[i]
    const f = best(p, c)
    if (!f) {
      const iii = ipt.split(EOL).slice(1)
      if (iii[0] == 1081) {
        console.log(rr.slice(-50).reduce((m, v, i) => {
          if (!m[i / 100 | 0]) m[i / 100 | 0] = []
          m[i / 100 | 0][i % 100] = v
          return m
        }, []).map(l => l.join(' ')).join('\n'), iii.slice(rr.length - 3, rr.length + 3))
      }
      return console.log('No solution')
    }
    rr.push(f)
    ils[i] = f
  }

  console.log(rr.join('\n'))

  function best (p, f) {
    let [f1, f2, f3, f4] = f.split('')
    let [p1, p2, p3, p4] = p.split('')
    if (p1 == 0) {
      if (+`${f2}${f3}${f4}` >= +`${p2}${p3}${p4}`)
        return `1${f2}${f3}${f4}`
      else
        return `2${f2}${f3}${f4}`
    }

    let res = search([p1, p2, p3, p4], [f1, f2, f3, f4])

    return test(p, res.split('')) && res

    function search ([p, ...ps], [f, ...fs]) {
      if (!ps.length) {
        return p
      }
      let fss = fs.join('')
      let pss = ps.join('')
      if (f + fss == p + pss) return p + pss
      let psn = +pss
      let fsn = +fss
      let pn = +p
      let fn = +f
      if (pn > fn || pn + 1 < fn) {
        if (psn > fsn) {
          return pn + 1 + fss
        } else {
          return pn + fss
        }
      } else if (pn + 1 == fn) {
        if (psn <= fsn) {
          return pn + fss
        } else {
          for (let i = 0; i < fs.length; i++) {
            if (fs[i] != 0) {
              fs[i] = 0
              break
            }
          }
          return f + fs.join('')
        }
      } else { // pn == fn
        if (ps.every(v => v == 9) && fs.filter(v => v != 9).length > 1)
          return pn + 1 + fss
        return f + search(ps, fs)
      }
    }

    function test(p, fs) {
      if (fs.length > 4) return
      let f = +fs.join('')
      if (f < +p) return
      if (f < 1000) return
      if (f > 2011) return
      return true
    }
  }
})