P18663 [HackerEarth] Rasta is a big fan of Kheshtaks. A Kheshtak is a rectangle that in each of it cells there is an integer.
普及
题目描述

Rasta is a big fan of Kheshtaks. A Kheshtak is a rectangle that in each of it cells there is an integer.

Today rasta came up with an interesting problem, Biggest Common Subsquare (BCS). A Kheshtak is called a Square if the number of its columns is equal to the number of its rows. A Square S is called a subsqaue of a Kheshtak A if and only if we can turn A to S by deleting some of its rows and some of its columns (maybe none).

He gives you two Kheshtaks, A and B (A one is n × m and B is x × y).

Input format
The first line of input contains n and m.

Then you are given A (n lines, in each line there are m space separated integers).

After that you are given x and y.

Then you are given B (x lines, in each line there are y space separated integers).

1 ≤ n, m, x, y ≤ 700 and all numbers in A and B are integers in the interval [1, 1000].

Output format
Print the size of BCS of A and B in a single line (size of a Square is number of its rows).

SAMPLE INPUT
3 3
1 2 0
1 2 1
1 2 3
3 3
0 1 2
1 1 2
3 1 2

SAMPLE OUTPUT
2

输入格式

见题面

输出格式

见题面

样例输入
15 15 457 757 679 204 781 371 983 732 192 194 803 376 84 977 294 464 81 696 442 436 374 380 670 766 959 407 745 909 496 167 392 911 561 498 515 512 600 936 993 685 921 613 966 602 481 51 828 54 266 41 55 943 874 524 247 37 341 871 883 343 46 540 395 316 132 372 828 395 832 267 905 893 570 140 911 156 255 721 327 397 327 91 234 514 954 767 933 270 60 923 106 400 244 676 920 759 305 950 924 967 755 570 869 125 647 885 397 196 406 595 482 739 519 596 790 710 97 172 225 873 220 746 487 953 196 279 273 970 641 190 832 61 785 685 607 580 515 98 47 574 691 86 10 592 52 533 771 963 133 565 624 348 117 646 706 844 260 900 964 938 423 556 574 624 827 545 343 746 196 525 179 442 780 547 376 663 122 721 466 6 66 485 370 100 350 615 220 679 848 504 593 28 65 221 722 715 575 401 179 575 497 653 590 842 956 512 84 561 673 641 669 346 995 39 89 406 428 307 899 446 835 635 954 126 865 15 15 704 653 625 209 672 131 435 793 660 64 52 530 986 643 334 347 645 590 585 739 519 596 790 18 111 938 154 48 403 260 350 419 710 97 172 225 873 190 226 37 376 681 563 217 682 949 501 832 61 785 685 607 627 180 905 504 593 28 65 221 127 470 533 771 963 133 565 818 983 767 956 512 84 561 673 692 371 423 556 574 624 827 430 305 755 950 612 7 489 471 516 334 663 122 721 466 6 468 229 916 443 985 540 659 267 224 237 12 56 993 714 521 10 837 604 293 159 818 162 224 423 401 495 814 567 879 834 47 574 691 964 741 708 992 702 864 431 368 904 869 923 383 646 706 844 561 56 349 874 547 55 435 777 927 585 968 724 196 525 179 361 204 728 989 464 507 590 415 725 141 682 659 100 350 615 220 442 524 460 661 55 945 291 94 349 579 54 253 844 284 561 498 870 653 844 198 103 549 534 215 271 249 399 426 852 54 266 170 973 400 8 224 608 645 823 19 445 211 250 977 904 401 542 822 283
样例输出
5