monk-and-iq_9751
Monk and his P-1 friends recently joined a college. He finds that N students have already applied for different courses before him.  Courses are assigned numbers from 1 to C. He and his friends will follow the following conditions when choosing courses:- 
They will choose the course i (1 ≤ i ≤ C), for which the value of z is minimum. Here, z = x*c where c is the number of students already enrolled in the course i and  x is the sum of IQ of the last two students who enrolled in that course. If a single student has applied for a course, then the value of x will be that student's IQ. If no student has enrolled for that course, then value of x will be 0. If the value of z is same for two courses, then they will choose the course with the minimum course number. You need to find which courses Monk and his friends should take after following the above conditions.
Note: Each of them will choose their courses, one at a time. Monk will choose his course first followed by his friends.

Input:
The first line contains the numbers C, P and N where C denotes the number of courses in that college, P denotes Monk and his friends and N denotes the number of students who have already applied for the courses.
The next line consists of N space separated integers Y[i] which denotes the IQ of the i^th student. Here, the i^th  student chooses the i^th course.  
The next line consists of P space separated integers X[i] which denotes the IQ of Monk and his friends.

Output:
Print P space separated integers in a line which denotes the course number which Monk and his friends have applied for.

Constraints:
1 ≤ C ≤ 100000
1 ≤ P ≤ 100000
1 ≤ N ≤ C
1 ≤ Y[i],X[i] ≤ 100000

SAMPLE INPUT
5 4 4
2 8 5 1
9 10 5 1

SAMPLE OUTPUT
5 4 1 3 

Explanation

In the sample test case, the last course has not been applied by anyone. So, its sum will be 0 initially. Hence, Monk will apply there as the value of z = 0.
Now Monk's first friend will apply for the 4th course as its value of z = 1, which is minimum of all the four courses.
Monk's second friend will apply for the 1st course as its value of z = 2, which is minimum of all the four courses.
Similarly, Monk's third friend will apply for the 3rd course as its value of z = 5, which is minimum of all the four courses.
import heapq

def solve(c, iqs, piqs):
    res = []
    q = [(0, i, 0, (0, 0)) for i in range(len(iqs) + 1, c + 1)]
    q += [(iq, i, 1, (0, iq)) for i, iq in enumerate(iqs, 1)]
    heapq.heapify(q)
    for iq in piqs:
        _, course, student_count, last_iqs = q[0]
        res.append(course)
        student_count += 1
        last_iqs = (last_iqs[1], iq)
        heapq.heapreplace(q, (sum(last_iqs) * student_count, course, student_count, last_iqs))
    return ' '.join(str(r) for r in res)

if __name__ == '__main__':
    ''' Once again one of the input is broken on codemonk ... '''
    c, p, _ = map(int, raw_input().split())
    iqs = map(int, raw_input().split())
    piqs = map(int, raw_input().split())
    piqs += [0] * (p - len(piqs)) # because input is truncated ...
    print solve(c, iqs, piqs)
5 4 4
2 8 5 1
9 10 5 1

SAMPLE 10 10 10
2 8 5 1 10 5 9 9 3 5
2 5 1 8 6 5 1 10 1 6 100 100 90
2 8 5 1 10 5 9 9 3 5 6 6 2 8 2 2 6 3 8 7 2 5 3 4 3 3 2 7 9 6 8 7 2 9 10 3 8 10 6 5 4 2 3 4 4 5 2 2 4 9 8 5 3 8 8 10 4 2 10 9 7 6 1 3 9 7 1 3 5 9 7 6 1 10 1 1 7 2 4 9 10 4 5 5 7 1 7 7 2 9
1 6 2 4 4 9 7 2 2 9 10 8 5 1 7 3 4 10 5 6 3 9 5 10 3 5 6 4 9 10 3 9 4 10 1 6 4 3 6 8 5 9 3 1 6 2 8 7 2 8 6 2 8 2 9 1 5 10 7 8 6 5 3 8 4 10 3 1 6 3 5 2 10 1 5 8 2 7 8 10 4 1 9 6 3 8 6 6 6 2 7 2 3 10 4 3 1 2 2 10 1000 1000 1000
42 18468 6335 26501 19170 15725 11479 29359 26963 24465 5706 28146 23282 16828 9962 492 2996 11943 4828 5437 32392 14605 3903 154 293 12383 17422 18717 19719 19896 5448 21727 14772 11539 1870 19913 25668 26300 17036 9895 28704 23812 31323 30334 17674 4665 15142 7712 28254 6869 25548 27645 32663 32758 20038 12860 8724 9742 27530 779 12317 3036 22191 1843 289 30107 9041 8943 19265 22649 27447 23806 15891 6730 24371 15351 15007 31102 24394 3549 19630 12624 24085 19955 18757 11841 4967 7377 13932 26309 16945 32440 24627 11324 5538 21539 16119 2083 22930 16542 4834 31116 4640 29659 22705 9931 13978 2307 31674 22387 5022 28746 26925 19073 6271 5830 26778 15574 5098 16513 23987 13291 9162 18637 22356 24768 23656 15575 4032 12053 27351 1151 16942 21725 13967 3431 31108 30192 18008 11338 15458 12288 27754 10384 14946 8910 32210 9759 24222 18589 6423 24947 27507 13031 16414 29169 901 32592 18763 1656 17411 6360 27625 20538 21549 6484 27596 4042 3603 24351 10292 30837 9375 11021 4597 24022 27349 23200 19669 24485 8282 4735 54 2000 26419 27939 6901 3789 18128 468 3729 14894 24649 22484 17808 2422 14311 6618 22814 9515 14310 7617 18936 17452 20601 5250 16520 31557 22799 30304 6225 11009 5845 32610 14990 32703 3196 20486 3094 14344 30524 1588 29315 9504 7449 25201 13459 6619 20581 19797 14799 15282 19590 20799 28010 27158 20473 23623 18539 12293 6039 24180 18191 29658 7959 6192 19816 22889 19157 11512 16203 2635 24273 20056 20329 22647 26363 4887 18876 28434 29870 20143 23845 1417 21882 31999 10323 18652 10022 5700 3558 28477 27893 24390 5076 10713 2601 2511 21004 26870 17862 14689 13402 9790 15256 16424 5003 10586 24183 10286 27089 31427 28618 23758 9833 30933 4170 2155 25722 17190 19977 31330 2369 28693 21426 10556 3435 16550 7442 9513 30146 18061 21719 3754 16140 12424 16280 25997 16688 12530 22550 17438 19867 12950 194 23196 3298 20417 28287 16106 24489 16283 12456 25735 18115 11702 31317 20672 5787 12264 4314 24356 31186 20054 913 10809 1833 20946 4314 27757 28322 19559 23647 27983 482 4145 23197 20223 7130 2162 5536 20451 11174 10467 12045 21660 26293 26440 17254 20025 26155 29511 4746 20650 13187 8314 4475 28023 2169 14019 18788 9906 17959 7392 10203 3626 26478 4415 9315 25825 29335 25875 24373 20160 11834 28071 7488 28298 7519 8178 17774 32271 1764 2669 17193 13986 3103 8481 29214 7628 4803 4100 30528 2626 1544 1925 11024 29973 13062 14182 31004 27433 17506 27594 22726 13032 8493 143 17223 31287 13065 7901 19188 8361 22414 30975 14271 29171 236 30834 19712 25761 18897 4668 7286 12551 141 13695 2696 21625 28020 2126 26577 21695 22659 26303 17372 22467 4679 22594 23852 25485 1019 28465 21120 23153 2801 18088 31061 1927 9011 4758 32171 20316 9577 30228 12044 22759 7165 5110 7883 17087 29566 3488 29578 14475 2626 25628 5630 31929 25424 28521 6903 14963 124 24597 3738 13262 10196 32526 1265 8261 6203 8117 5031 20327 29012 30772 6412 25548 21154 21521 29791 14925 30189 21764 4941 20852 18663 13830 30901 17714 18959 17579 8366 13008 11478 1201 26059 6440 2304 12761 19358 2325 6478 5109 21114 14888 19802 22851 14461 22429 12994 27385 19406 6541 31112 28705 12836 32357 6073 29351 18824 14486 20557 23217 1627 9358 8527 13358 29338 23272 23870 29362 12897 13023 29618 10113 12718 18697 11586 24042 24424 24130 24230 4566 6560 8933 22297 29856 12054 16963 3585 29735 6655 16973 21458 14370 22533 2964 2608 2484 912 11636 10068 22849 4676 12939 2224 22143 23755 6512 22742 20176 21460 17826 3222 17871 1627 31935 15206 31784 23851 17399 22280 22702 12194 12735 1638 26535 5557 1994 10177 25706 6963 10549 15882 301 14414 16642 19856 24856 13143 11463 27612 30878 20425 32679 1753 18444 28297 12674 10041 9314 876 20073 12819 611 1018 14933 28113 30696 13170 23832 20041 26489 28686 19091 19498 2590 25991 15146 19354 19315 18652 26741 22045 11259 336 8760 11193 7606 25265 12182 28504 3830 23776 20609 29293 5998 17550 29557 25562 31628 6468 29542 26130 31241 27814 29175 20602 6078 20216 8684 8214 23993 25825 5602 23393 15760 2671 26429 28028 4085 10076 18787 15499 24971 6288 23848 32605 504 21222 22664 5707 2364 9011 22172 27490 18241 12165 25543 7620 20914 7592 6705 31819 9233 751 25206 4976 1540 304 11423 21099 11248 13585 13649 2972 17865 22914 11076 21546 28713 17547 18679 1770 15263 8520 13986 28290 15945 2866 18541 23246 25509 28319 27871 9602 28324 21133 24473 27153 25088 28571 29764 29902 17104 14424 3528 11601 26970 14016 5566 29 21544 25348 2089 2944 12638 22410 26464 5050 4682 1589 11343 609 32061 21222 1759 29955 20889 14147 691 7950 12844 21431 25621 749 27068 4537 20784 18036 32227 15186 7039 9854 25630 11225 15749 19924 3360 32258 24767 4945 14956 23319 32727 25412 21026 20356 31002 22550 9497 18585 9516 17965 23343 8076 17914 16143 31197 21949 25073 20427 14607 26174 24430 32405 6706 20627 29813 19376 30094 16566 16037 14737 29142 30815 5995 8257 6653 23937 30839 20483 1356 21016 1132 18231 17842 14626 2012 32638 4187 19691 1651 5663 21635 10894 10354 21417 13453 14009 7263 22234 5455 16304 16635 26304 14257 149 11125 12318 4214 27110 24029 29201 21081 21319 16859 24051 24156 31362 15265 11904 3677 29644 26910 14903 3562 28490 24949 1283 13654 30675 2221 5403 6924 3832 19370 3879 20260 19009 22620 23972 30004 21946 9782 26505 12393 32686 25314 6699 5590 12723 5939 19038 6411 31462 6235 12509 9962 3960 6494 1516 25270 24938 28870 59 14701 13972 26265 15118 16216 24556 7816 18331 3040 30213 29289 28083 1955 16086 20711 24485 24775 8381 29816 25952 6542 18116 1680 17111 25899 23074 789 23978 18133 29957 28690 26114 10009 12942 15791 1724 21364 29 25185 24779 7201 5072 1886 21975 1072 11334 22868 26154 14296 32169 20826 9677 15630 28651 2599 3310 4694 4687 30081 10117 12250
7160 27948 21522 31501 29061 4241 7684 8219 7152 24017 1282 25122 18204 1490 6320 27462 10596 1810 14561 18973 19680 25054 18687 26490 32228 23750 12974 3715 714 27981 31660 15114 242 6373 29435 8730 13062 25114 14659 10447 21635 5645 10354 15723 26229 3620 24229 18087 12674 14848 28747 7495 10537 1455 1415 17393 5196 28707 26327 20799 7916 26083 15604 16403 14645 13313 2041 6699 26554 10060 4550 12533 26881 11206 24487 22692 21570 89 26417 22915 5484 21189 2669 2953 27241 22493 7993 20526 17827 13299 1514 24190 14791 18321 4918 5484 21193 13418 20818 18536 40 11919 23639 14900 29811 28134 24042 14835 7692 21465 27676 5763 7468 6475 20367 23564 23335 6352 29915 4057 9969 2333 3375 24167 31457 15293 8764 28604 20406 13318 8526 22010 8408 10828 8636 18996 1504 20308 27267 11136 1369 25611 31534 29774 1224 31096 7161 6648 31211 27888 14645 2714 16703 29833 3566 15651 15812 20433 25036 1964 9732 28863 24119 12297 8786 12521 16062 27294 8272 26360 24762 15220 32692 28761 30254 28045 31819 822 24562 5236 31038 23717 29457 19479 4500 7967 11631 10969 4600 30003 7599 6628 16316 19579 595 1980 4383 15568 25637 10522 15051 28602 12246 15351 13986 7210 4838 231 10170 27244 8131 24232 16294 21591 32053 25595 2296 21959 9465 7090 15107 333 30125 26379 31462 19748 7148 21052 11718 11367 5817 5967 16474 18562 23329 17200 1965 28391 23324 12549 7967 1794 29621 20413 26541 9326 1642 26092 3187 2409 16854 18390 12399 11653 23949 13257 10632 7329 19784 18609 27855 16920 12098 19174 4100 29752 31201 11080 1116 21494 11417 1166 28289 21727 2062 731 16347 338 4472 27026 29966 20205 25932 11116 7620 5957 7449 18632 4524 2266 19631 26690 30403 9290 23175 23942 31954 6596 14175 4711 29239 6848 14629 1579 5609 29677 7446 22313 19127 875 29991 2711 4048 24379 1188 1693 25224 16372 20503 29357 27993 951 25707 29207 10280 23908 6481 27864 19914 1038 21219 23219 19143 30381 1671 17540 2398 10259 1815 28624 16073 10018 23615 26784 7618 5947 10534 23952 4677 3321 26192 547 27288 8992 29379 27481 4489 23504 16488 6788 15863 8703 8117 10839 15251 32550 28297 21056 12520 22841 11863 13304 1689 19677 17799 10072 21482 30678 28697 30830 29826 18366 9100 19408 11120 8445 27134 7472 30571 29173 30868 3121 31838 1661 1308 27513 9764 12177 7921 17927 26767 4935 3871 20167 16560 14597 968 28260 23378 9714 2759 25438 1224 7594 8082 10332 17897 23350 20581 5315 21080 22075 16029 27527 11273 26737 32354 19522 8192 26455 6536 14979 92 1574 14775 12136 16277 5123 15818 26991 20738 27256 15990 28297 29342 8229 17964 29808 17419 21427 16448 9019 20183 8970 25418 26160 25599 8900 6861 16089 29361 27105 13334 20058 15446 1468 21095 2305 2512 27197 28245 18463 17920 12881 25711 11798 8588 17559 22304 4276 9183 12381 26583 23999 19825 22218 2916 11729 12104 13404 32166 31078 7103 24214 6243 9268 21638 2546 4471 21179 23018 11293 25649 15900 16214 3683 27130 31278 10522 25704 26167 25039 22380 15130 2417 7544 25260 21475 12211 30741 3309 16419 24116 30227 19632 20701 17462 25274 29938 11953 17198 18365 7786 11786 16933 783 13836 13208 20574 28409 21713 15617 23353 20586 17594 25043 31575 32654 22291 24766 7423 32417 28661 3328 1985 29446 27406 12320 2393 13459 15780 13279 18390 26416 31192 10348 32507 21152 5928 31447 11493 27806 9272 28616 29166 18732 17874 13937 10194 25896 10027 10177 29712 32544 16232 1498 22931 29287 4192 20422 3474 18536 17060 32101 5045 29755 17085 14250 25977 27766 17332 24839 10453 5958 19160 550 14878 15550 10427 28378 3368 29550 894 14165 10670 15160 22094 14747 18163 14943 2607 26423 19114 20705 3064 4908 12051 30215 927 23598 5224 5178 4279 1810 375 22296 12343 23940 6032 8135 12157 25848 15777 5001 20627 483 1696 30865 944 23338 22313 21782 23042 4570 3689 1189 5546 8475 13882 14267 31497 31327 32399 4499 18234 12767 2067 22589 28639 20296 16909 27376 4129 5809 24455 29345 9970 24017 10159 212 2709 16751 9597 4275 13665 20249 31382 7773 20418 30489 22897 18560 7040 23205 27320 12330 9284 19030 8689 2780 22872 2268 17757 6881 29870 9711 11552 477 21284 1416 32163 8617 8710 26450 24887 32606 1492 603 1275 23728 7750 2320 23807 31614 2958 10600 29609 16294 22749 23903 18520 8990 28712 8102 328 12353 31532 22681 29878 30310 21936 6001 19780 11447 29962 27579 19870 30529 26852 29449 30558 583 22848 28391 6445 26588 9658 30480 2091 5041 2573 7138 2194 6443 27609 3344 10646 12216 13732 6295 6287 18788 25374 5619 12121 30631 8873 4498 16891 4737 12312 19593 28552 21961 19639 25734 31299 26819 30860 14341 27398 1008 20701 23239 997 10538 14323 11904 17934 8688 10781 29649 3827 14334 25591 26485 4268 23584 15851 16319 10646 12105 24825 7748 24385 8671 14516 18901 137 7514 18061 17584 13058 27661 14932 4854 28570 21315 29692 17760 12921 5006 21151 7214 25132 17244 29889 22113 12803 14283 19929 298 951 28607 13582 23458 3152 13617 20798 8891 16454 26826 1604 22903 19175 11184 18299 24920 5368 23456 29566 30487 7839 5437 7474 26521 12417 12455 26119 4382 10279 27728 19834 1212 25510 14859 6623 23564 4223 25190 15965 5923 25028 29242 25146 5827 29052 9856 27992 1747 20809 19046 15872 19725 3656 15267 27615 20471 11321 2311 15438 10772 23520 24406 11223 7515 28842 14422 12532 23272 22932 39 7193 29426 8521 9427 14581 253 14730 17446 5366 26704 5587 27584 3851 13482 22844 8040 5293 29489 7069 6563 12320 6059 2549 31365 19446 16880 26125 22728 20438 30623 10584 26907 31355 9745 20254 12220 7423 139 2521 28745 7002 3768 26592 20436 22054 32598 11074 23861 24997 4911 22773 29604 11780 13387 17200 11143 1249 3428 4885 19848 12 13722 5523 31723 23946 17512 20363 1566 21728 25047 7473 6802 20878 9969 24758 19146 14041 25209 1060 5554 4301 5593 21129 27697 22147 15964 27735 25601
5 4 1 3 4 1 9 3 6 10 4 2 9 9 91 92 93 94 95 96 97 98 99 100 4 63 67 73 75 76 86 91 1 13 15 16 21 27 33 42 47 48 58 78 89 93 98 99 9 18 23 25 26 36 43 53 64 68 24 41 44 45 49 57 73 79 82 94 95 3 6 10 22 40 46 52 69 83 84 11 12 17 30 39 62 72 92 20 28 32 61 66 71 77 85 87 88 97 2 9 14 19 31 37 51 54 55 68 76 7 8 29 34 50 775 977 1 183 939 495 447 428 881 24 325 439 65 25 628 733 669 190 355 16 712 787 648 794 799 729 60 966 645 157 593 345 649 463 984 858 132 528 501 903 856 264 935 732 415 222 785 557 609 619 866 160 962 975 639 790 403 747 347 64 35 982 416 470 952 622 184 862 98 778 452 298 360 379 906 599 531 108 534 716 303 196 592 278 649 660 994 277 591 414 487 252 404 701 449 467 753 779 325 590 739 17 62 948 219 407 645 217 607 327 995 812 136 307 484 770 80 271 900 25 583 169 386 896 191 497 314 188 676 909 911 23 933 129 168 704 412 356 297 864 884 341 349 388 377 801 190 576 175 103 46 444 597 459 784 997 996 182 373 472 108 411 19 101 258 517 815 87 731 287 111 505 783 981 275 119 536 480 206 907 20 31 876 361 95 621 774 924 698 489 867 270 11 715 339 116 213 926 850 680 739 241 551 692 246 503 211 930 115 709 3 639 975 162 928 509 151 530 685 535 166 934 602 546 960 577 198 228 852 585 923 726 840 74 50 187 493 908 625 806 359 479 980 874 445 88 384 309 225 397 399 725 672 202 723 410 48 946 481 432 795 245 829 184 504 400 695 851 502 487 181 376 434 525 957 408 427 749 559 694 57 495 670 146 578 68 966 471 717 67 123 728 644 389 558 173 824 224 310 200 826 475 759 991 58 148 918 284 295 807 40 382 106 15 932 972 269 643 595 705 568 999 623 499 385 290 171 592 267 870 144 222 364 626 306 288 276 346 869 278 212 174 417 742 882 884 363 671 412 809 736 668 94 985 140 786 377 734 634 527 7 250 34 571 771 594 336 395 86 480 169 895 18 477 365 130 581 721 674 617 1000 340 142 240 61 883 26 920 316 333 931 320 446 82 780 642 569 925 618 532 339 647 549 796 56 565 930 930 598 973 324 543 526 566 154 426 419 431 633 653 375 628 498 122 452 560 283 472 872 227 737 738 904 934 934 448 520 403 89 135 941 107 406 750 386 873 773 380 264 793 420 880 437 988 201 197 220 588 775 629 769 541 486 554 881 22 836 861 282 940 847 444 33 463 231 538 192 899 514 650 145 816 494 215 77 943 47 662 805 611 449 285 748 894 232 76 141 707 118 128 116 992 447 303 6 810 700 974 627 73 752 846 953 330 97 315 831 251 944 317 332 877 155 286 784 120 207 100 308 845 467 878 25 630 319 428 14 890 133 91 582 586 39 482 768 963 377 300 405 429 369 457 614 161 27 862 151 322 204 423 745 681 524 45 522 749 493 401 195 606 860 281 740 608 830 479 383 827 139 803 312 384 468 335 961 189 968 243 859 720 812 160 947 408 640 2 239 754 412 825 150 124 268 665 519 746 570 28 502 85 159 706 381 553 259 443 203 523 376 913 927 114 658 249 5 433 69 664 663 533 910 843 545 659 352 35 233 81 179 865 441 29 858 397 230 539 247 271 307 631 323 30 36 811 84 301 370 55 655 344 254 646 95 262 394 604 693 358 912 474 506 255 821 698 328 637 835 362 213 237 855 218 164 555 229 205 691 678 841 374 338 954 802 234 990 518 957 792 724 348 279 857 820 888 735 537 465 761 511 994 713 789 225 907 889 976 871 305 797 587 807 605 512 96 776 743 165 450 868 366 454 313 134 32 516 136 607 669 265 917 884 833 983 667 211 999 600 718 63 397 875 307 307 615 579 932 125 110 781 435 576 542 458 194 991 589 321 823 460 67 914 256 70 455 714 616 105 425 603 478 870 209 199 596 540 986 248 741 99 965 466 326 357 178 556 755 562 13 817 828 699 972 903 668 238 353 127 935 601 294 677 72 42 654 263 710 613 461 563 853 915 967 121 696 176 886 572 891 83 574 892 242 289 149 575 253 778 170 342 75 393 274 79 573 838 504 962 306 10 762 180 955 331 945 496 93 193 270 933 814 126 956 979 911 632 937 152 902 708 923 314 834 764 978 226 730 382 673 936 922 726 777 168 819 869 491 462 756 722 51 510 683 798 488 808 37 67 624 299 334 442 390 697 392 807 964 959 661 318 559 529 971 687 987 371 837 276 942 367 38 456 879 90 257 185 702 368 782 387 656 731 4 919 867 620 453 666 379 117 503 280 898 190 113 9 772 428 621 800 717 717 717 291 583 885 535 763 236 18 258 177 131 544 422 71 719 904 60 153 59 198 424 167 635 163 52 576 812 143 350 689 758 780 780 273 186 106 354 382 235 451 378 703 396 951 651 12 994 49 329