The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in $$$a$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 100$$$) — the sequence $$$a$$$.

Print one integer — the minimum non-negative integer value $$$D$$$ such that if you add this value to some $$$a_i$$$, subtract this value from some $$$a_i$$$ and leave some $$$a_i$$$ without changes, all obtained values become equal. If it is impossible to choose such value $$$D$$$, print -1.

You are given a sequence $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ integers.You can choose any non-negative integer $$$D$$$ (i.e. $$$D \ge 0$$$), and for each $$$a_i$$$ you can:  add $$$D$$$ (only once), i. e. perform $$$a_i := a_i + D$$$, or  subtract $$$D$$$ (only once), i. e. perform $$$a_i := a_i - D$$$, or  leave the value of $$$a_i$$$ unchanged. It is possible that after an operation the value $$$a_i$$$ becomes negative.Your goal is to choose such minimum non-negative integer $$$D$$$ and perform changes in such a way, that all $$$a_i$$$ are equal (i.e. $$$a_1=a_2=\dots=a_n$$$).Print the required $$$D$$$ or, if it is impossible to choose such value $$$D$$$, print -1.For example, for array $$$[2, 8]$$$ the value $$$D=3$$$ is minimum possible because you can obtain the array $$$[5, 5]$$$ if you will add $$$D$$$ to $$$2$$$ and subtract $$$D$$$ from $$$8$$$. And for array $$$[1, 4, 7, 7]$$$ the value $$$D=3$$$ is also minimum possible. You can add it to $$$1$$$ and subtract it from $$$7$$$ and obtain the array $$$[4, 4, 4, 4]$$$.

Input:
6
1 4 4 7 4 1

Output: 3

Input:
5
2 2 5 2 5

Output: 3

Input:
4
1 3 3 7

Output: -1

Input:
2
2 8

Output: 3

Input:
1
100

Output: 0

Input:
2
1 1

Output: 0

Input:
100
49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100

Output: -1

Input:
5
1 2 2 1 1

Output: 1

Input:
3
1 2 4

Output: -1

Input:
3
1 3 4

Output: -1

Input:
100
1 1 1 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 99

Input:
3
2 6 6

Output: 2

Input:
5
2 4 6 8 10

Output: -1

Input:
5
1 1 1 1 1

Output: 0

Input:
3
2 3 4

Output: 1

Input:
4
2 3 6 9

Output: -1

Input:
4
4 2 6 6

Output: 2

Input:
5
1 2 3 4 5

Output: -1

Input:
4
1 4 7 10

Output: -1

Input:
4
2 2 10 10

Output: 4

Input:
3
7 5 3

Output: 2

Input:
2
2 7

Output: 5

Input:
4
2 2 12 12

Output: 5

Input:
2
5 8

Output: 3

Input:
3
52 52 54

Output: 1

Input:
4
1 2 3 4

Output: -1

Input:
2
3 1

Output: 1

Input:
2
2 5

Output: 3

Input:
5
1 5 1 5 1

Output: 2

Input:
4
4 4 4 4

Output: 0

Input:
4
4 2 2 4

Output: 1

Input:
5
1 4 7 10 13

Output: -1

Input:
4
2 2 4 4

Output: 1

Input:
4
1 2 3 6

Output: -1

Input:
3
1 5 3

Output: 2

Input:
2
3 8

Output: 5

Input:
2
2 9

Output: 7

Input:
6
1 3 5 1 5 5

Output: 2

Input:
100
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Output: -1

Input:
3
5 5 3

Output: 1

Input:
2
1 100

Output: 99

Input:
3
1 5 9

Output: 4

Input:
2
3 6

Output: 3

Input:
4
1 3 5 7

Output: -1

Input:
2
1 8

Output: 7

Input:
4
1 1 1 1

Output: 0

Input:
3
2 4 6

Output: 2

Input:
3
3 7 2

Output: -1

Input:
2
5 4

Output: 1

Input:
3
4 6 8

Output: 2

Input:
2
20 11

Output: 9

Input:
5
1 1 2 3 4

Output: -1

Input:
3
1 3 1

Output: 1

Input:
2
100 1

Output: 99

Input:
4
4 6 8 2

Output: -1

Input:
2
4 3

Output: 1

Input:
2
9 1

Output: 4

Input:
2
6 5

Output: 1

Input:
4
2 2 2 1

Output: 1

Input:
2
1 4

Output: 3

Input:
4
2 4 6 8

Output: -1

Input:
3
1 7 4

Output: 3

Input:
3
1 5 1

Output: 2

Input:
3
1 3 3

Output: 1

Input:
2
5 10

Output: 5

Input:
3
6 8 4

Output: 2

Input:
3
3 3 9

Output: 3

Input:
3
100 100 4

Output: 48

Input:
2
11 10

Output: 1

Input:
3
2 2 8

Output: 3

Input:
2
12 11

Output: 1

Input:
3
1 3 5

Output: 2

Input:
7
2 2 5 8 8 8 8

Output: 3

Input:
3
6 1 11

Output: 5

Input:
2
4 5

Output: 1

Input:
2
13 12

Output: 1

Input:
2
93 7

Output: 43

Input:
2
1 7

Output: 3

Input:
9
54 16 67 14 49 84 30 44 59

Output: -1

Input:
2
4 7

Output: 3

Input:
4
1 2 3 3

Output: 1

Input:
2
8 7

Output: 1

Input:
5
1 3 1 3 3

Output: 1

Input:
3
1 9 5

Output: 4

Input:
2
9 8

Output: 1

Input:
3
10 16 22

Output: 6

Input:
6
4 2 2 4 4 4

Output: 1

Input:
10
1 2 3 4 5 6 7 8 9 10

Output: -1

Input:
2
1 10

Output: 9

Input:
4
10 16 22 28

Output: -1

Input:
4
1 7 4 10

Output: -1

Input:
4
2 5 8 11

Output: -1

Input:
4
100 100 100 4

Output: 48

Input:
4
2 2 1 3

Output: 1

Input:
5
5 5 5 5 11

Output: 3

Input:
3
1 50 99

Output: 49

Input:
2
1 5

Output: 2

Input:
2
1 2

Output: 1

Input:
3
3 3 1

Output: 1

Input:
5
6 4 2 1 1

Output: -1

Input:
4
4 7 4 10

Output: 3

Input:
4
7 8 8 6

Output: 1

Input:
5
7 6 5 4 6

Output: -1

Input:
2
5 3

Output: 1

Input:
3
1 1 1

Output: 0

Input:
3
5 2 8

Output: 3

Input:
3
2 10 6

Output: 4

Input:
4
2 6 10 14

Output: -1

Input:
4
2 4 4 6

Output: 2

Input:
4
2 4 4 4

Output: 1

Input:
3
1 7 19

Output: -1

Input:
2
1 11

Output: 5

Input:
11
69 8 70 23 47 72 48 41 63 86 20

Output: -1

Input:
9
1 4 7 7 4 1 4 7 1

Output: 3

Input:
3
4 3 5

Output: 1

Input:
5
4 2 6 6 6

Output: 2

Input:
2
72 32

Output: 20

Input:
5
7 9 5 7 7

Output: 2

Input:
4
1 1 5 1

Output: 2

Input:
4
2 4 6 10

Output: -1

Input:
5
10 8 6 4 2

Output: -1

Input:
4
4 4 12 12

Output: 4

Input:
8
2 2 2 6 6 6 4 4

Output: 2

Input:
4
1 3 4 5

Output: -1

Input:
2
4 18

Output: 7

Input:
5
1 3 5 1 5

Output: 2

Input:
3
1 100 99

Output: -1

Input:
4
4 3 2 1

Output: -1

Input:
8
1 11 1 11 1 11 1 21

Output: 10

Input:
5
1 3 2 1 4

Output: -1

Input:
8
1 1 1 1 4 7 7 1

Output: 3

Input:
2
4 19

Output: 15

Input:
3
5 3 1

Output: 2

Input:
6
1 3 5 5 3 1

Output: 2

Input:
10
10 20 30 10 20 30 10 20 30 31

Output: -1

Input:
4
1 4 3 5

Output: -1

Input:
3
1 2 6

Output: -1

Input:
10
20 20 20 20 20 20 20 21 19 18

Output: -1

Input:
5
1 2 3 4 4

Output: -1

Input:
5
1 5 9 1 5

Output: 4

Input:
6
1 3 5 3 5 1

Output: 2

Input:
2
52 50

Output: 1

Input:
4
3 3 9 9

Output: 3

Input:
9
4 6 6 4 6 7 8 6 4

Output: -1

Input:
9
2 4 6 4 6 2 5 6 2

Output: -1

Input:
100
72 72 89 89 89 89 55 72 55 72 89 55 55 89 55 72 72 55 55 89 89 89 55 89 89 55 55 89 72 72 89 89 55 55 89 89 55 55 89 72 55 55 72 72 72 72 72 89 72 55 72 72 55 55 89 72 72 89 89 55 89 72 72 89 55 55 55 72 55 55 89 89 89 89 72 55 72 72 55 55 55 55 72 55 72 72 55 72 55 72 55 55 72 72 55 89 89 72 72 89

Output: 17

Input:
2
1 6

Output: 5

Input:
4
2 6 4 4

Output: 2

Input:
10
3 5 5 7 7 5 5 1 1 1

Output: -1

Input:
6
4 4 2 2 6 6

Output: 2

Input:
7
7 7 5 7 8 5 8

Output: -1

Input:
6
4 4 4 2 6 8

Output: -1

Input:
2
2 1

Output: 1

Input:
4
1 5 3 3

Output: 2

Input:
4
1 3 4 7

Output: -1


The first line of the input contains three positive integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 7\cdot10^8$$$) — the number of daily rations of fish food, rabbit stew and chicken stakes in Polycarps backpack correspondingly.

NoteIn the first example the best day for start of the trip is Sunday. In this case, during Sunday and Monday the cat will eat fish food, during Tuesday — rabbit stew and during Wednesday — chicken stake. So, after four days of the trip all food will be eaten.In the second example Polycarp can start his trip in any day of the week. In any case there are food supplies only for one week in Polycarps backpack.In the third example Polycarp can start his trip in any day, excluding Wednesday, Saturday and Sunday. In this case, the cat will eat three different dishes in three days. Nevertheless that after three days of a trip there will be $$$99$$$ portions of rabbit stew in a backpack, can cannot eat anything in fourth day of a trip.

Polycarp has a cat and his cat is a real gourmet! Dependent on a day of the week he eats certain type of food:  on Mondays, Thursdays and Sundays he eats fish food;  on Tuesdays and Saturdays he eats rabbit stew;  on other days of week he eats chicken stake. Polycarp plans to go on a trip and already packed his backpack. His backpack contains:  $$$a$$$ daily rations of fish food;  $$$b$$$ daily rations of rabbit stew;  $$$c$$$ daily rations of chicken stakes. Polycarp has to choose such day of the week to start his trip that his cat can eat without additional food purchases as long as possible. Print the maximum number of days the cat can eat in a trip without additional food purchases, if Polycarp chooses the day of the week to start his trip optimally.

Input: 2 1 1

Output: 4

Input: 3 2 2

Output: 7

Input: 1 100 1

Output: 3

Input: 30 20 10

Output: 39

Input: 700000000 200000000 300000000

Output: 700000003

Input: 300000000 700000000 400000000

Output: 700000002

Input: 500000000 200000000 700000000

Output: 700000003

Input: 700000000 700000000 700000000

Output: 1633333336

Input: 92 54 80

Output: 192

Input: 97 46 46

Output: 163

Input: 13 77 34

Output: 33

Input: 4 1 2

Output: 6

Input: 1009859 14748096 15475634

Output: 2356339

Input: 2 100 100

Output: 6

Input: 200 2 3

Output: 9

Input: 2 8 9

Output: 6

Input: 201 4 5

Output: 16

Input: 3 1 4

Output: 6

Input: 202 4 5

Output: 16

Input: 205 2 4

Output: 10

Input: 203 3 6

Output: 13

Input: 3 2 1

Output: 6

Input: 21234578 1231455 1230047

Output: 4305167

Input: 5 4 3

Output: 12

Input: 10 8 6

Output: 23

Input: 27 20 20

Output: 65

Input: 20 16 12

Output: 46

Input: 11144477 3123445 6688711

Output: 10932060

Input: 525643356 245126545 242111421

Output: 847389976

Input: 1 1 2

Output: 4

Input: 4 4 2

Output: 9

Input: 580491178 465290676 24999591

Output: 87498571

Input: 309767158 518372594 115844198

Output: 405454697

Input: 600025643 600010745 600014575

Output: 1400059835

Input: 659209689 118781819 382068338

Output: 415736369

Input: 600019415 600004367 600015718

Output: 1400045303

Input: 177674746 123877503 565008408

Output: 414574410

Input: 123243 122112 234567

Output: 287569

Input: 650439292 352470919 347331093

Output: 1215658828

Input: 690005222 690012314 690019663

Output: 1610012186

Input: 222222 2222222 22223

Output: 77783

Input: 155247014 622599781 457401709

Output: 362243034

Input: 10012219 123221 1234

Output: 4323

Input: 1 2 3

Output: 5

Input: 4 2 3

Output: 9

Input: 27053 31618 3317

Output: 11612

Input: 1 2 9

Output: 5

Input: 5 4 1

Output: 6

Input: 1 10 2

Output: 5

Input: 1 5 6

Output: 5

Input: 1 7 10

Output: 5

Input: 1 1527 11861

Output: 5

Input: 5 5 1

Output: 6

Input: 5 1 6

Output: 6

Input: 699999999 466666666 466666665

Output: 1633333330

Input: 31750 16654 16655

Output: 58291


The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of figures. The second line contains $$$n$$$ integer numbers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 3$$$, $$$a_i \ne a_{i + 1}$$$) — types of the figures.

NoteHere are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way.The distinct points where figures touch are marked red.In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points.

The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type.

The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier.Future students will be asked just a single question. They are given a sequence of integer numbers $$$a_1, a_2, \dots, a_n$$$, each number is from $$$1$$$ to $$$3$$$ and $$$a_i \ne a_{i + 1}$$$ for each valid $$$i$$$. The $$$i$$$-th number represents a type of the $$$i$$$-th figure:  circle;  isosceles triangle with the length of height equal to the length of base;  square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that:  $$$(i + 1)$$$-th figure is inscribed into the $$$i$$$-th one;  each triangle base is parallel to OX;  the triangle is oriented in such a way that the vertex opposite to its base is at the top;  each square sides are parallel to the axes;  for each $$$i$$$ from $$$2$$$ to $$$n$$$ figure $$$i$$$ has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure.The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it?So can you pass the math test and enroll into Berland State University?

Input:
3
2 1 3

Output:
Finite
7

Output:
Finite
7

Input:
3
1 2 3

Output: Infinite

Input:
99
3 1 3 1 3 1 2 1 3 1 3 1 2 1 3 1 3 1 3 1 3 1 2 1 2 1 3 1 2 1 2 1 3 1 3 1 2 1 3 1 3 1 3 1 3 1 2 1 2 1 3 1 3 1 2 1 2 1 2 1 3 1 3 1 3 1 2 1 2 1 3 1 2 1 2 1 3 1 3 1 2 1 3 1 3 1 2 1 3 1 3 1 3 1 3 1 2 1 2

Output:
Finite
341

Output:
Finite
341

Input:
100
3 1 3 1 2 1 2 3 1 2 3 2 3 2 3 2 3 1 2 1 2 3 1 2 3 2 1 2 1 3 2 3 1 2 3 1 2 3 1 3 2 1 2 1 3 2 1 2 1 3 1 3 2 1 2 1 2 1 2 3 2 1 2 1 2 3 2 3 2 1 3 2 1 2 1 2 1 3 1 3 1 2 1 2 3 2 1 2 3 2 3 1 3 2 3 1 2 3 2 3

Output: Infinite

Input:
100
1 2 1 2 1 2 1 2 1 3 1 3 1 2 1 3 1 2 1 3 1 2 1 3 1 2 1 2 1 3 1 2 1 2 1 3 1 3 1 2 1 2 1 3 1 2 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 3 1 3 1 3 1 2 1 2 1 2 1 2 1 2 1 2 1 3 1 3 1 2 1 2 1 2 1 3 1 2 1 3 1 2 1 2

Output:
Finite
331

Output:
Finite
331

Input:
100
1 3 2 3 2 1 3 2 3 1 2 1 3 1 2 1 3 1 2 1 3 2 3 2 1 2 1 3 2 1 3 2 3 1 3 1 3 1 3 1 3 2 3 2 3 2 3 1 2 1 2 3 1 3 2 3 2 3 2 3 2 3 2 1 3 1 2 3 1 2 3 2 1 2 3 1 2 1 3 2 1 2 1 2 1 3 1 2 1 2 1 2 3 1 2 1 3 1 3 1

Output: Infinite

Input:
99
1 2 1 2 1 2 1 3 1 2 1 3 1 3 1 2 1 3 1 3 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 3 1 2 1 3 1 3 1 2 1 2 1 3 1 2 1 2 1 2 1 3 1 2 1 2 1 3 1 2 1 2 1 3 1 3 1 2 1 2 1 3 1 2 1 3 1 2 1 3 1 3 1 3 1 2 1 3 1

Output:
Finite
331

Output:
Finite
331

Input:
100
2 1 3 1 3 1 3 1 2 1 2 1 3 1 2 1 3 1 2 1 3 1 2 1 3 1 3 1 3 1 2 1 2 1 2 1 3 1 3 1 2 1 2 1 2 1 2 1 2 1 2 1 3 1 2 1 2 1 3 1 3 1 2 1 2 1 2 1 3 1 2 1 2 1 3 1 2 1 3 1 3 1 3 1 2 1 2 1 3 1 2 1 2 1 2 1 3 1 3 1

Output:
Finite
329

Output:
Finite
329

Input:
2
3 2

Output: Infinite

Input:
3
3 1 2

Output:
Finite
6

Output:
Finite
6

Input:
11
3 1 2 1 3 1 2 1 3 1 2

Output:
Finite
32

Output:
Finite
32

Input:
2
3 1

Output:
Finite
4

Output:
Finite
4

Input:
4
1 3 1 2

Output:
Finite
10

Output:
Finite
10

Input:
4
3 1 2 3

Output: Infinite

Input:
8
3 1 2 1 3 1 2 1

Output:
Finite
22

Output:
Finite
22

Input:
8
3 1 2 1 3 1 3 1

Output:
Finite
25

Output:
Finite
25

Input:
2
1 2

Output:
Finite
3

Output:
Finite
3

Input:
4
3 1 2 1

Output:
Finite
9

Output:
Finite
9

Input:
16
3 1 2 1 3 1 2 1 2 1 3 1 3 1 2 1

Output:
Finite
49

Output:
Finite
49

Input:
5
3 1 2 1 2

Output:
Finite
12

Output:
Finite
12

Input:
4
2 3 1 2

Output: Infinite

Input:
3
1 3 2

Output: Infinite

Input:
4
3 1 3 2

Output: Infinite

Input:
2
2 3

Output: Infinite

Input:
3
2 3 1

Output: Infinite

Input:
2
2 1

Output:
Finite
3

Output:
Finite
3

Input:
3
1 2 1

Output:
Finite
6

Output:
Finite
6

Input:
5
2 1 3 1 2

Output:
Finite
13

Output:
Finite
13

Input:
15
2 1 2 1 2 1 2 1 2 1 2 1 2 1 2

Output:
Finite
42

Output:
Finite
42

Input:
15
1 2 1 2 1 2 1 2 1 2 1 2 1 2 1

Output:
Finite
42

Output:
Finite
42


The first line contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).

Print one integer: the number of different numbers that are reachable from $$$n$$$.

Let's denote a function $$$f(x)$$$ in such a way: we add $$$1$$$ to $$$x$$$, then, while there is at least one trailing zero in the resulting number, we remove that zero. For example,   $$$f(599) = 6$$$: $$$599 + 1 = 600 \rightarrow 60 \rightarrow 6$$$;  $$$f(7) = 8$$$: $$$7 + 1 = 8$$$;  $$$f(9) = 1$$$: $$$9 + 1 = 10 \rightarrow 1$$$;  $$$f(10099) = 101$$$: $$$10099 + 1 = 10100 \rightarrow 1010 \rightarrow 101$$$. We say that some number $$$y$$$ is reachable from $$$x$$$ if we can apply function $$$f$$$ to $$$x$$$ some (possibly zero) times so that we get $$$y$$$ as a result. For example, $$$102$$$ is reachable from $$$10098$$$ because $$$f(f(f(10098))) = f(f(10099)) = f(101) = 102$$$; and any number is reachable from itself.You are given a number $$$n$$$; your task is to count how many different numbers are reachable from $$$n$$$.


The first line contains a single integer $$$n$$$ $$$(1 \le n \le 100)$$$ — the number of benches in the park. The second line contains a single integer $$$m$$$ $$$(1 \le m \le 10\,000)$$$ — the number of people additionally coming to the park. Each of the next $$$n$$$ lines contains a single integer $$$a_i$$$ $$$(1 \le a_i \le 100)$$$ — the initial number of people on the $$$i$$$-th bench.

NoteIn the first example, each of four benches is occupied by a single person. The minimum $$$k$$$ is $$$3$$$. For example, it is possible to achieve if two newcomers occupy the first bench, one occupies the second bench, one occupies the third bench, and two remaining — the fourth bench. The maximum $$$k$$$ is $$$7$$$. That requires all six new people to occupy the same bench.The second example has its minimum $$$k$$$ equal to $$$15$$$ and maximum $$$k$$$ equal to $$$15$$$, as there is just a single bench in the park and all $$$10$$$ people will occupy it.

Print the minimum possible $$$k$$$ and the maximum possible $$$k$$$, where $$$k$$$ is the maximum number of people sitting on one bench after additional $$$m$$$ people came to the park.

There are $$$n$$$ benches in the Berland Central park. It is known that $$$a_i$$$ people are currently sitting on the $$$i$$$-th bench. Another $$$m$$$ people are coming to the park and each of them is going to have a seat on some bench out of $$$n$$$ available.Let $$$k$$$ be the maximum number of people sitting on one bench after additional $$$m$$$ people came to the park. Calculate the minimum possible $$$k$$$ and the maximum possible $$$k$$$.Nobody leaves the taken seat during the whole process.

Input:
4
6
1
1
1
1

Output: 3 7

Input:
1
10
5

Output: 15 15

Input:
3
6
1
6
5

Output: 6 12

Input:
3
7
1
6
5

Output: 7 13

Input:
10
1000
100
100
100
100
100
100
100
100
100
100

Output: 200 1100

Input:
10
1
3
3
2
3
3
3
3
3
3
3

Output: 3 4

Input:
51
10000
54
23
93
86
57
68
42
33
47
18
78
41
35
92
32
97
74
93
27
59
90
23
79
96
77
29
88
83
83
46
94
61
56
68
43
15
79
26
36
99
36
55
77
23
15
12
84
57
82
33
14

Output: 254 10099

Input:
100
8000
88
40
39
88
33
2
60
93
62
18
44
53
79
55
34
71
45
82
97
96
96
25
83
83
54
45
47
59
94
84
12
33
97
24
71
28
81
89
52
87
96
35
34
31
45
42
14
74
8
68
61
36
65
87
31
18
38
84
28
74
98
77
15
85
82
64
2
93
31
78
64
35
6
77
55
70
83
42
98
38
59
99
27
66
10
54
22
94
21
21
89
86
73
12
86
1
98
94
48
51

Output: 137 8099

Input:
10
10
1
1
1
1
1
1
1
1
1
1

Output: 2 11

Input:
10
10
1
1
1
2
1
1
1
1
1
1

Output: 3 12

Input:
100
1000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

Output: 11 1001

Input:
1
10000
57

Output: 10057 10057

Input:
1
1000
48

Output: 1048 1048

Input:
2
1000
1
7

Output: 504 1007

Input:
5
10
68
87
14
68
23

Output: 87 97

Input:
10
20
80
41
15
77
91
82
15
83
36
3

Output: 91 111

Input:
20
3303
25
14
77
85
66
97
9
60
79
39
47
2
97
71
45
36
92
54
62
53

Output: 221 3400

Input:
40
10000
54
5
23
10
10
77
15
84
92
63
34
21
12
56
25
32
28
50
50
86
3
26
39
69
43
99
71
38
15
33
50
79
54
84
33
47
14
66
99
25

Output: 296 10099

Input:
66
1000
27
10
63
17
28
89
34
86
27
62
26
18
25
31
45
44
92
56
47
18
53
56
79
3
9
32
88
52
21
57
97
84
50
12
6
52
21
37
24
84
44
81
41
47
7
67
93
43
100
64
82
46
28
48
1
34
28
82
15
47
1
19
34
12
48
48

Output: 100 1100

Input:
78
9909
63
38
36
74
56
3
27
99
71
95
81
39
45
75
32
42
5
23
45
46
63
69
75
80
89
48
86
74
18
87
4
55
54
8
15
91
39
13
89
95
75
38
31
27
48
81
47
91
62
88
53
45
73
79
42
57
72
99
16
52
15
52
95
98
26
84
4
88
31
26
9
86
29
45
62
18
99
78

Output: 182 10008

Input:
89
9080
29
88
62
50
63
91
24
3
93
76
73
50
26
32
87
93
48
52
97
68
100
84
42
93
59
68
46
19
53
30
53
20
65
43
22
98
46
45
38
37
45
31
2
24
56
74
93
48
40
68
7
4
68
44
31
63
32
21
94
92
99
93
17
18
18
48
71
38
67
67
29
87
38
66
73
61
59
98
91
33
22
56
75
91
73
83
61
41
70

Output: 158 9180

Input:
90
10000
43
85
87
11
50
66
30
90
23
22
16
20
2
60
8
26
56
89
50
40
3
23
9
66
36
85
19
49
87
97
20
23
75
32
3
38
71
54
79
46
62
27
16
2
24
55
76
83
55
47
46
41
63
30
22
84
70
81
59
44
56
23
67
9
60
54
95
36
73
60
33
20
18
67
20
18
7
65
55
54
45
32
38
52
15
15
88
44
47
88

Output: 157 10097

Input:
99
1092
28
89
65
40
96
47
76
2
62
59
60
90
91
12
10
71
57
97
18
52
82
32
71
77
39
16
84
89
26
95
45
15
93
73
63
32
33
3
64
12
92
12
92
80
3
80
47
26
69
84
96
40
86
95
55
13
64
73
52
37
13
98
86
95
43
67
18
98
100
66
5
25
87
25
37
10
29
43
84
72
17
70
31
96
27
38
1
40
74
17
58
39
18
5
41
15
95
53
77

Output: 100 1192

Input:
100
66
95
19
88
15
29
52
37
75
21
90
93
75
91
71
53
55
90
78
19
63
43
25
52
10
55
76
47
42
57
45
35
53
2
62
61
99
59
59
43
45
31
37
50
68
51
91
34
48
40
69
77
33
16
64
19
82
76
35
41
41
79
29
69
100
30
81
47
55
79
21
59
3
11
43
49
100
27
87
64
8
6
7
88
71
98
6
32
53
91
85
60
35
55
5
44
66
76
99
7
58

Output: 100 166

Input:
100
50
20
63
60
88
7
22
90
15
27
82
37
44
42
50
33
46
7
97
93
5
68
79
76
3
82
5
51
79
17
1
1
93
52
88
23
23
49
86
64
18
36
53
49
47
11
19
6
79
64
59
56
96
15
72
81
45
24
55
31
2
74
64
57
65
71
44
8
7
38
50
67
1
79
89
16
35
10
72
69
8
56
42
44
95
25
26
16
84
36
73
17
61
91
15
19
78
44
77
96
58

Output: 97 147

Input:
100
100
82
51
81
14
37
17
78
92
64
15
8
86
89
8
87
77
66
10
15
12
100
25
92
47
21
78
20
63
13
49
41
36
41
79
16
87
87
69
3
76
80
60
100
49
70
59
72
8
38
71
45
97
71
14
76
54
81
4
59
46
39
29
92
3
49
22
53
99
59
52
74
31
92
43
42
23
44
9
82
47
7
40
12
9
3
55
37
85
46
22
84
52
98
41
21
77
63
17
62
91

Output: 100 200

Input:
100
1000
91
17
88
51
92
47
85
3
82
61
2
48
55
56
71
1
12
78
80
31
42
33
85
99
25
25
37
18
29
53
84
88
4
55
24
3
53
53
1
95
36
84
65
5
40
52
49
77
48
5
77
50
31
80
100
46
28
29
34
83
26
3
100
63
100
23
76
4
70
57
10
58
7
20
84
44
86
54
2
11
85
3
35
83
96
97
55
75
39
39
39
61
19
86
76
72
29
69
20
17

Output: 100 1100

Input:
100
2000
77
39
49
44
85
10
28
49
92
64
67
39
65
53
81
58
63
80
74
27
10
45
9
26
31
98
55
61
51
43
2
95
77
52
79
42
89
99
68
6
29
71
63
96
11
10
77
32
89
28
12
19
84
34
22
69
86
24
35
40
5
100
55
35
69
60
74
72
37
44
82
83
91
1
68
24
79
39
47
57
16
76
64
34
72
3
48
35
15
70
33
78
31
48
10
30
55
43
6
93

Output: 100 2100

Input:
100
5000
30
90
42
18
55
6
50
65
31
89
47
48
76
58
10
18
2
79
39
9
7
89
100
1
44
23
99
12
23
15
55
16
95
40
23
37
87
42
54
51
11
57
44
61
32
74
44
5
1
96
32
30
21
13
77
48
62
6
28
7
49
87
33
60
72
64
88
86
34
13
23
59
46
39
5
45
81
88
75
97
40
88
46
100
87
30
37
13
68
43
9
32
48
28
100
14
28
67
73
26

Output: 100 5100

Input:
100
9990
22
89
54
55
92
20
84
12
93
6
73
50
23
62
97
88
59
87
4
14
49
28
47
93
5
36
50
78
83
99
100
27
24
23
27
84
67
72
45
51
53
32
60
9
77
63
15
98
17
49
58
77
50
31
10
6
16
74
50
99
100
36
51
71
89
65
17
62
32
3
25
39
19
2
25
75
25
89
87
13
96
91
10
1
94
39
10
64
26
28
32
7
16
34
96
28
24
35
82
99

Output: 150 10090

Input:
100
10000
25
90
88
97
71
24
53
4
32
69
53
93
80
14
30
65
9
56
3
23
70
25
31
6
13
19
49
58
95
40
26
72
75
44
86
13
94
11
83
75
26
64
100
84
82
35
80
41
40
8
5
28
3
98
1
22
73
33
44
22
2
72
68
80
39
92
75
67
61
26
89
59
19
29
7
60
91
34
73
53
22
2
85
22
47
92
90
99
100
44
82
19
1
49
100
13
67
32
75
98

Output: 151 10100

Input:
100
10000
45
35
50
78
28
97
37
92
91
51
93
33
70
43
53
78
31
14
29
67
11
7
41
85
70
27
74
15
15
10
52
50
66
81
95
25
28
86
17
89
19
87
85
38
79
19
92
85
62
71
18
72
92
18
93
56
64
54
3
38
18
77
3
54
70
49
56
91
60
56
34
54
42
41
75
90
43
21
18
69
76
51
24
50
82
56
62
45
50
67
20
31
12
10
10
7
75
84
17
18

Output: 151 10097

Input:
2
50
1
51

Output: 51 101

Input:
3
100
52
2
2

Output: 52 152

Input:
100
300
1
1
2
2
1
1
1
1
1
1
2
2
1
2
2
1
2
2
2
2
2
1
1
1
2
1
2
1
1
1
2
1
1
1
2
1
2
1
2
1
2
1
2
1
2
1
1
1
1
2
2
2
1
1
2
1
2
2
2
1
1
2
2
2
2
2
2
1
1
2
2
2
2
1
2
2
2
1
2
1
1
2
2
1
1
1
1
2
1
2
2
1
2
2
1
1
2
1
2
2

Output: 5 302

Input:
100
3000
99
100
99
99
100
99
100
99
99
100
99
100
100
99
100
100
99
99
99
100
100
100
100
100
99
100
100
99
100
100
99
99
99
99
100
100
99
99
99
100
99
100
100
99
99
100
100
100
99
99
99
100
99
99
99
100
99
99
100
99
100
100
100
99
99
100
100
100
99
100
100
99
99
100
100
99
100
100
100
99
99
100
100
99
100
99
99
100
99
99
99
100
99
100
100
100
99
100
99
100

Output: 130 3100

Input:
100
10000
54
54
50
52
55
51
50
53
50
56
50
51
51
52
54
50
54
52
53
56
55
51
52
55
56
52
52
56
51
56
51
51
55
54
52
55
51
55
56
54
55
54
56
56
51
52
52
56
51
52
52
55
53
51
55
51
54
52
56
51
50
52
52
55
53
52
53
53
51
52
54
50
53
53
56
52
52
54
54
52
55
53
54
53
54
55
56
51
54
55
50
56
52
50
55
55
54
55
50
50

Output: 154 10056

Input:
100
2325
78
78
80
78
79
80
79
80
79
80
78
80
79
80
78
78
79
80
80
80
79
79
79
79
80
80
79
80
79
80
79
79
79
79
80
80
80
78
80
80
80
78
80
80
80
80
78
78
79
79
79
79
80
78
80
78
80
80
80
79
78
79
80
80
78
78
80
78
80
79
78
80
78
78
80
80
78
78
79
78
78
79
79
78
80
78
78
80
80
80
78
80
78
79
80
78
80
79
78
79

Output: 103 2405

Input:
100
3241
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100

Output: 133 3341

Input:
100
9675
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

Output: 98 9676

Input:
100
9435
36
37
36
36
37
34
35
37
36
34
37
35
34
35
35
36
36
37
37
36
37
34
36
35
37
36
34
35
35
35
34
36
37
36
35
34
35
34
34
34
36
37
37
34
37
34
37
36
35
36
37
35
37
35
36
34
36
35
35
35
37
37
36
34
35
35
36
35
34
35
35
35
37
36
34
35
37
36
36
36
36
35
34
37
35
34
37
37
36
37
37
34
36
35
36
35
34
37
34
35

Output: 130 9472

Input:
100
9999
4
5
1
8
8
2
9
5
8
6
10
8
2
10
5
10
10
3
3
1
9
7
1
5
3
7
1
3
7
3
7
8
8
8
10
3
9
9
5
9
4
7
3
8
8
6
9
4
4
8
3
6
3
3
7
10
4
2
4
3
9
10
2
4
3
1
3
4
4
4
5
8
6
3
9
10
7
7
10
2
6
10
7
7
10
6
2
9
8
1
6
7
3
5
8
6
1
3
8
5

Output: 106 10009

Input:
100
2344
42
40
69
62
79
43
36
55
44
13
48
69
46
61
70
75
51
67
57
35
5
19
6
92
78
59
42
3
81
41
70
90
99
93
44
22
80
62
69
95
12
63
99
42
12
9
72
8
19
33
81
33
66
32
10
50
98
83
11
25
81
13
56
60
4
89
75
59
92
7
55
84
48
85
82
18
29
68
60
25
26
37
12
15
27
17
85
20
16
47
76
55
75
66
47
98
90
32
47
9

Output: 99 2443

Input:
100
1
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100

Output: 101 101

Input:
100
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

Output: 2 2

Input:
100
2
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50

Output: 51 52

Input:
100
300
1
1
2
2
1
2
2
2
1
2
2
2
1
2
1
1
2
2
1
1
2
1
1
2
1
2
2
2
2
2
2
1
1
1
2
2
2
2
1
1
1
2
1
1
2
2
2
1
2
2
2
1
2
2
1
2
1
1
2
2
2
2
1
2
2
2
1
1
2
1
1
1
1
2
2
2
2
2
1
2
1
1
1
1
2
1
1
2
2
1
2
1
1
1
2
2
93
1
2
2

Output: 93 393

Input:
100
3000
2
4
4
5
3
3
5
5
2
4
4
2
3
1
5
5
5
3
3
1
2
2
3
3
5
5
3
5
2
1
4
4
5
3
4
3
1
3
5
1
3
3
3
5
3
4
1
3
1
5
5
5
5
3
5
5
2
1
4
2
5
1
1
5
1
3
3
1
4
2
4
3
4
4
5
2
5
95
1
2
1
2
5
3
3
2
3
4
2
3
3
2
3
4
4
4
4
3
3
2

Output: 95 3095

Input:
100
10000
51
53
53
54
52
52
51
53
52
55
53
51
56
55
55
50
53
53
50
52
53
50
51
56
54
50
53
51
54
50
50
55
50
53
52
52
54
56
56
52
54
56
52
52
55
54
56
53
54
53
55
50
55
54
54
56
50
50
56
55
55
53
52
54
52
53
50
53
54
52
53
52
52
56
51
53
53
55
50
50
51
55
55
51
50
51
50
54
93
50
50
55
55
50
54
55
55
53
53
56

Output: 154 10093

Input:
100
2325
30
18
24
24
23
23
18
28
26
28
29
23
22
19
26
26
29
20
26
30
30
26
27
25
24
25
27
22
22
19
23
22
25
27
25
21
25
26
22
20
29
21
21
22
26
29
18
22
19
23
29
30
25
22
24
30
22
23
22
26
24
19
27
20
27
29
30
22
30
26
22
19
23
20
21
26
20
30
26
24
30
20
26
24
97
25
23
19
22
19
23
29
28
28
26
29
23
26
28
20

Output: 97 2422

Input:
100
3241
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
93
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10

Output: 93 3334

Input:
100
9675
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
99
1
1
1
1
1
1
1
1

Output: 99 9774

Input:
10
1
5
5
5
5
4
5
5
5
5
5

Output: 5 6

Input:
100
9435
15
16
21
24
22
27
24
18
26
25
17
25
14
26
15
20
17
21
17
24
26
26
27
21
24
20
26
25
25
20
22
19
14
16
17
27
16
21
16
27
21
14
24
27
24
19
25
23
21
19
16
14
25
18
96
25
24
15
20
21
22
15
24
23
14
22
26
26
16
17
23
17
25
22
21
27
26
19
25
25
23
16
25
19
15
19
18
27
17
21
25
20
27
14
26
15
27
15
24
18

Output: 117 9531

Input:
100
9999
1
10
5
2
9
2
10
10
9
6
10
8
10
2
10
8
5
4
8
6
3
4
8
6
1
3
8
8
7
7
5
3
2
8
4
3
7
9
9
10
7
1
10
6
2
8
7
4
3
5
9
1
10
3
4
10
1
7
1
91
10
4
7
6
4
3
2
6
3
5
5
2
3
3
1
10
10
7
10
7
8
4
6
6
1
10
2
9
6
5
1
10
8
2
10
7
8
5
3
6

Output: 107 10090

Input:
100
2344
23
10
18
15
32
22
10
38
32
31
39
8
26
16
22
10
23
11
25
36
24
40
7
27
43
28
23
25
7
23
22
7
43
6
22
38
7
32
35
12
41
43
97
3
37
29
27
36
17
2
27
35
16
10
3
19
12
20
29
7
14
5
31
26
10
4
3
15
32
42
24
36
41
43
36
23
14
32
3
32
21
30
32
25
32
8
27
11
19
15
34
12
41
11
39
20
14
23
7
43

Output: 97 2441

Input:
2
1
5
1

Output: 5 6

Input:
4
1
1
9
9
9

Output: 9 10

Input:
2
3
1
100

Output: 100 103

Input:
2
16
2
100

Output: 100 116

Input:
2
1
1
100

Output: 100 101

Input:
3
7
1
6
1

Output: 6 13

Input:
2
1
10
1

Output: 10 11

Input:
3
1
1
1
99

Output: 99 100

Input:
2
2
1
100

Output: 100 102


The first line contains a string S (1 ≤ |S| ≤ 105). The second line contains a string T (1 ≤ |T| ≤ 105), each of these strings consists only of uppercase English letters 'A', 'B' and 'C'. The third line contains the number of queries Q (1 ≤ Q ≤ 105). The following Q lines describe queries. The i-th of these lines contains four space separated integers ai, bi, ci, di. These represent the i-th query: is it possible to create T[ci..di] from S[ai..bi] by applying the above transitions finite amount of times? Here, U[x..y] is a substring of U that begins at index x (indexed from 1) and ends at index y. In particular, U[1..|U|] is the whole string U. It is guaranteed that 1 ≤ a ≤ b ≤ |S| and 1 ≤ c ≤ d ≤ |T|.

NoteIn the first query we can achieve the result, for instance, by using transitions .The third query asks for changing AAB to A — but in this case we are not able to get rid of the character 'B'.

Print a string of Q characters, where the i-th character is '1' if the answer to the i-th query is positive, and '0' otherwise.

Alice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times:   A  BC  B  AC  C  AB  AAA  empty string Note that a substring is one or more consecutive characters. For given queries, determine whether it is possible to obtain the target string from source.

Input:
AABCCBAAB
ABCB
5
1 3 1 2
2 2 2 4
7 9 1 1
3 4 2 3
4 5 1 3

Output: 10011

Input:
AAAAAA
AAAAAA
30
3 4 1 2
3 3 4 4
5 6 3 4
3 3 2 3
6 6 1 5
2 4 4 6
1 6 2 5
6 6 3 4
3 5 1 4
4 5 3 6
2 3 2 4
3 4 4 4
6 6 4 6
3 3 2 5
1 5 3 3
4 6 1 2
6 6 6 6
3 3 3 4
6 6 6 6
5 6 4 4
6 6 5 5
2 3 1 4
3 6 4 5
3 5 6 6
4 5 2 6
5 6 6 6
1 4 2 5
4 5 2 5
4 5 1 3
2 2 4 6

Input:
A
A
1
1 1 1 1

Output: 1

Input:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
10000
64 79 89 99
11 80 46 89
33 45 11 20
75 84 24 100
13 20 87 92
19 51 27 93
7 9 25 99
5 82 2 29
70 76 7 31
46 46 40 47
78 94 6 79
75 84 68 91
93 100 13 46
56 99 56 91
14 100 39 80
47 65 73 95
80 93 69 96
73 80 93 99
75 83 87 90
74 94 39 74
96 98 14 53
25 54 25 83
73 100 48 80
84 ...

Input:
CCBACACBCCCBBAAC
CACCAAABAACBBBBAC
20
7 7 2 15
3 11 14 15
4 9 6 12
10 15 13 17
10 16 5 14
14 15 12 16
16 16 16 16
3 15 9 14
10 12 8 12
15 15 9 10
14 15 8 15
7 14 17 17
15 15 17 17
15 15 5 9
4 14 12 17
13 15 8 12
1 4 2 2
6 13 17 17
11 14 5 11
15 16 2 9

Input:
ABAAAAAA
ABABBAAAAAA
5
3 8 4 11
3 8 3 11
2 8 2 11
1 8 1 11
1 8 2 11

Output: 00111

Input:
ABC
ABC
9
1 1 1 1
1 1 2 2
1 1 3 3
2 2 1 1
2 2 2 2
2 2 3 3
3 3 1 1
3 3 2 2
3 3 3 3

Output: 100011011

Input:
A
BB
1
1 1 1 2

Output: 1

Input:
BBAACCBACACBCCCBBAAC
CACCAAABAACBBBBACABC
1
3 10 6 13

Output: 0

Input:
AAAAACAAAAAB
AAAAABAAAAAC
20
1 6 10 12
10 12 7 12
9 12 8 12
2 6 8 12
7 12 2 6
9 12 7 12
1 6 10 12
4 6 3 6
7 12 7 12
4 6 5 6
3 6 12 12
5 6 8 12
9 12 1 6
2 6 3 6
10 12 2 6
1 6 12 12
7 12 3 6
9 12 3 6
10 12 10 12
11 12 11 12

Input:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC
1000
151 202 152 202
80 101 149 202
3 101 124 202
103 202 127 202
150 202 71 101
140 202 47 101
...

Input:
AAABABACACACAAACAC
AABCBBACABACBBCBCC
20
6 17 17 17
14 17 13 14
1 13 7 12
11 17 5 17
6 10 16 17
16 17 16 16
15 17 17 17
15 15 7 10
1 4 10 14
4 11 2 17
6 9 1 7
16 16 11 18
4 14 6 17
1 17 6 18
13 18 15 18
1 12 5 11
8 8 12 17
10 15 3 7
17 17 9 14
6 17 6 6

Input:
AAACAABB
CACBCCBB
10
2 2 4 5
4 4 3 3
1 4 1 8
5 5 2 8
7 7 3 4
6 6 2 2
1 7 1 1
6 7 7 8
4 6 6 8
8 8 6 8

Output: 1111010011

Input:
A
CB
1
1 1 1 2

Output: 1

Input:
BCBBC
ABBCB
5
2 2 2 4
3 4 2 4
1 2 2 2
2 3 4 5
5 5 2 4

Output: 10011