結果

問題 No.368 LCM of K-products
ユーザー rickythetarickytheta
提出日時 2016-04-30 00:09:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 54,314 bytes
コンパイル時間 1,500 ms
コンパイル使用メモリ 170,164 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 21:11:48
合計ジャッジ時間 2,778 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
4,348 KB
testcase_01 AC 34 ms
4,348 KB
testcase_02 AC 16 ms
4,348 KB
testcase_03 AC 20 ms
4,348 KB
testcase_04 AC 22 ms
4,348 KB
testcase_05 AC 16 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 10 ms
4,348 KB
testcase_14 AC 17 ms
4,348 KB
testcase_15 AC 18 ms
4,348 KB
testcase_16 AC 15 ms
4,348 KB
testcase_17 AC 13 ms
4,348 KB
testcase_18 AC 19 ms
4,348 KB
testcase_19 AC 5 ms
4,348 KB
testcase_20 AC 12 ms
4,348 KB
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 17 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 7 ms
4,348 KB
testcase_34 AC 17 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:76:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   76 |   scanf("%d%d",&n,&k);
      |   ~~~~~^~~~~~~~~~~~~~
main.cpp:77:16: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   77 |   REP(i,n)scanf("%d",&a[i]);
      |           ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int n,k;
int a[1252];
int st[1252];

// montgomery multiplication
// mod N
// R = 1<<30
// M(x) = xR = MR(xR2)
// MR(x) = xR^-1

constexpr ll R = 1073741824;
constexpr ll Rmask = 1073741823;
constexpr int Rshift = 30;
constexpr ll Rinv = 73699066ll;
constexpr ll N = 1000000007;
constexpr ll Ninv = 79133769ll;
constexpr ll R2 = 536396504ll;
constexpr ll M1 = 73741817ll;

ll MR(ll x){
  ll t = (x+((x*Ninv)&Rmask)*N)>>Rshift;
  return (t>=N?t-N:t);
}

// 3401
int ps[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,4007,4013,4019,4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,4943,4951,4957,4967,4969,4973,4987,4993,4999,5003,5009,5011,5021,5023,5039,5051,5059,5077,5081,5087,5099,5101,5107,5113,5119,5147,5153,5167,5171,5179,5189,5197,5209,5227,5231,5233,5237,5261,5273,5279,5281,5297,5303,5309,5323,5333,5347,5351,5381,5387,5393,5399,5407,5413,5417,5419,5431,5437,5441,5443,5449,5471,5477,5479,5483,5501,5503,5507,5519,5521,5527,5531,5557,5563,5569,5573,5581,5591,5623,5639,5641,5647,5651,5653,5657,5659,5669,5683,5689,5693,5701,5711,5717,5737,5741,5743,5749,5779,5783,5791,5801,5807,5813,5821,5827,5839,5843,5849,5851,5857,5861,5867,5869,5879,5881,5897,5903,5923,5927,5939,5953,5981,5987,6007,6011,6029,6037,6043,6047,6053,6067,6073,6079,6089,6091,6101,6113,6121,6131,6133,6143,6151,6163,6173,6197,6199,6203,6211,6217,6221,6229,6247,6257,6263,6269,6271,6277,6287,6299,6301,6311,6317,6323,6329,6337,6343,6353,6359,6361,6367,6373,6379,6389,6397,6421,6427,6449,6451,6469,6473,6481,6491,6521,6529,6547,6551,6553,6563,6569,6571,6577,6581,6599,6607,6619,6637,6653,6659,6661,6673,6679,6689,6691,6701,6703,6709,6719,6733,6737,6761,6763,6779,6781,6791,6793,6803,6823,6827,6829,6833,6841,6857,6863,6869,6871,6883,6899,6907,6911,6917,6947,6949,6959,6961,6967,6971,6977,6983,6991,6997,7001,7013,7019,7027,7039,7043,7057,7069,7079,7103,7109,7121,7127,7129,7151,7159,7177,7187,7193,7207,7211,7213,7219,7229,7237,7243,7247,7253,7283,7297,7307,7309,7321,7331,7333,7349,7351,7369,7393,7411,7417,7433,7451,7457,7459,7477,7481,7487,7489,7499,7507,7517,7523,7529,7537,7541,7547,7549,7559,7561,7573,7577,7583,7589,7591,7603,7607,7621,7639,7643,7649,7669,7673,7681,7687,7691,7699,7703,7717,7723,7727,7741,7753,7757,7759,7789,7793,7817,7823,7829,7841,7853,7867,7873,7877,7879,7883,7901,7907,7919,7927,7933,7937,7949,7951,7963,7993,8009,8011,8017,8039,8053,8059,8069,8081,8087,8089,8093,8101,8111,8117,8123,8147,8161,8167,8171,8179,8191,8209,8219,8221,8231,8233,8237,8243,8263,8269,8273,8287,8291,8293,8297,8311,8317,8329,8353,8363,8369,8377,8387,8389,8419,8423,8429,8431,8443,8447,8461,8467,8501,8513,8521,8527,8537,8539,8543,8563,8573,8581,8597,8599,8609,8623,8627,8629,8641,8647,8663,8669,8677,8681,8689,8693,8699,8707,8713,8719,8731,8737,8741,8747,8753,8761,8779,8783,8803,8807,8819,8821,8831,8837,8839,8849,8861,8863,8867,8887,8893,8923,8929,8933,8941,8951,8963,8969,8971,8999,9001,9007,9011,9013,9029,9041,9043,9049,9059,9067,9091,9103,9109,9127,9133,9137,9151,9157,9161,9173,9181,9187,9199,9203,9209,9221,9227,9239,9241,9257,9277,9281,9283,9293,9311,9319,9323,9337,9341,9343,9349,9371,9377,9391,9397,9403,9413,9419,9421,9431,9433,9437,9439,9461,9463,9467,9473,9479,9491,9497,9511,9521,9533,9539,9547,9551,9587,9601,9613,9619,9623,9629,9631,9643,9649,9661,9677,9679,9689,9697,9719,9721,9733,9739,9743,9749,9767,9769,9781,9787,9791,9803,9811,9817,9829,9833,9839,9851,9857,9859,9871,9883,9887,9901,9907,9923,9929,9931,9941,9949,9967,9973,10007,10009,10037,10039,10061,10067,10069,10079,10091,10093,10099,10103,10111,10133,10139,10141,10151,10159,10163,10169,10177,10181,10193,10211,10223,10243,10247,10253,10259,10267,10271,10273,10289,10301,10303,10313,10321,10331,10333,10337,10343,10357,10369,10391,10399,10427,10429,10433,10453,10457,10459,10463,10477,10487,10499,10501,10513,10529,10531,10559,10567,10589,10597,10601,10607,10613,10627,10631,10639,10651,10657,10663,10667,10687,10691,10709,10711,10723,10729,10733,10739,10753,10771,10781,10789,10799,10831,10837,10847,10853,10859,10861,10867,10883,10889,10891,10903,10909,10937,10939,10949,10957,10973,10979,10987,10993,11003,11027,11047,11057,11059,11069,11071,11083,11087,11093,11113,11117,11119,11131,11149,11159,11161,11171,11173,11177,11197,11213,11239,11243,11251,11257,11261,11273,11279,11287,11299,11311,11317,11321,11329,11351,11353,11369,11383,11393,11399,11411,11423,11437,11443,11447,11467,11471,11483,11489,11491,11497,11503,11519,11527,11549,11551,11579,11587,11593,11597,11617,11621,11633,11657,11677,11681,11689,11699,11701,11717,11719,11731,11743,11777,11779,11783,11789,11801,11807,11813,11821,11827,11831,11833,11839,11863,11867,11887,11897,11903,11909,11923,11927,11933,11939,11941,11953,11959,11969,11971,11981,11987,12007,12011,12037,12041,12043,12049,12071,12073,12097,12101,12107,12109,12113,12119,12143,12149,12157,12161,12163,12197,12203,12211,12227,12239,12241,12251,12253,12263,12269,12277,12281,12289,12301,12323,12329,12343,12347,12373,12377,12379,12391,12401,12409,12413,12421,12433,12437,12451,12457,12473,12479,12487,12491,12497,12503,12511,12517,12527,12539,12541,12547,12553,12569,12577,12583,12589,12601,12611,12613,12619,12637,12641,12647,12653,12659,12671,12689,12697,12703,12713,12721,12739,12743,12757,12763,12781,12791,12799,12809,12821,12823,12829,12841,12853,12889,12893,12899,12907,12911,12917,12919,12923,12941,12953,12959,12967,12973,12979,12983,13001,13003,13007,13009,13033,13037,13043,13049,13063,13093,13099,13103,13109,13121,13127,13147,13151,13159,13163,13171,13177,13183,13187,13217,13219,13229,13241,13249,13259,13267,13291,13297,13309,13313,13327,13331,13337,13339,13367,13381,13397,13399,13411,13417,13421,13441,13451,13457,13463,13469,13477,13487,13499,13513,13523,13537,13553,13567,13577,13591,13597,13613,13619,13627,13633,13649,13669,13679,13681,13687,13691,13693,13697,13709,13711,13721,13723,13729,13751,13757,13759,13763,13781,13789,13799,13807,13829,13831,13841,13859,13873,13877,13879,13883,13901,13903,13907,13913,13921,13931,13933,13963,13967,13997,13999,14009,14011,14029,14033,14051,14057,14071,14081,14083,14087,14107,14143,14149,14153,14159,14173,14177,14197,14207,14221,14243,14249,14251,14281,14293,14303,14321,14323,14327,14341,14347,14369,14387,14389,14401,14407,14411,14419,14423,14431,14437,14447,14449,14461,14479,14489,14503,14519,14533,14537,14543,14549,14551,14557,14561,14563,14591,14593,14621,14627,14629,14633,14639,14653,14657,14669,14683,14699,14713,14717,14723,14731,14737,14741,14747,14753,14759,14767,14771,14779,14783,14797,14813,14821,14827,14831,14843,14851,14867,14869,14879,14887,14891,14897,14923,14929,14939,14947,14951,14957,14969,14983,15013,15017,15031,15053,15061,15073,15077,15083,15091,15101,15107,15121,15131,15137,15139,15149,15161,15173,15187,15193,15199,15217,15227,15233,15241,15259,15263,15269,15271,15277,15287,15289,15299,15307,15313,15319,15329,15331,15349,15359,15361,15373,15377,15383,15391,15401,15413,15427,15439,15443,15451,15461,15467,15473,15493,15497,15511,15527,15541,15551,15559,15569,15581,15583,15601,15607,15619,15629,15641,15643,15647,15649,15661,15667,15671,15679,15683,15727,15731,15733,15737,15739,15749,15761,15767,15773,15787,15791,15797,15803,15809,15817,15823,15859,15877,15881,15887,15889,15901,15907,15913,15919,15923,15937,15959,15971,15973,15991,16001,16007,16033,16057,16061,16063,16067,16069,16073,16087,16091,16097,16103,16111,16127,16139,16141,16183,16187,16189,16193,16217,16223,16229,16231,16249,16253,16267,16273,16301,16319,16333,16339,16349,16361,16363,16369,16381,16411,16417,16421,16427,16433,16447,16451,16453,16477,16481,16487,16493,16519,16529,16547,16553,16561,16567,16573,16603,16607,16619,16631,16633,16649,16651,16657,16661,16673,16691,16693,16699,16703,16729,16741,16747,16759,16763,16787,16811,16823,16829,16831,16843,16871,16879,16883,16889,16901,16903,16921,16927,16931,16937,16943,16963,16979,16981,16987,16993,17011,17021,17027,17029,17033,17041,17047,17053,17077,17093,17099,17107,17117,17123,17137,17159,17167,17183,17189,17191,17203,17207,17209,17231,17239,17257,17291,17293,17299,17317,17321,17327,17333,17341,17351,17359,17377,17383,17387,17389,17393,17401,17417,17419,17431,17443,17449,17467,17471,17477,17483,17489,17491,17497,17509,17519,17539,17551,17569,17573,17579,17581,17597,17599,17609,17623,17627,17657,17659,17669,17681,17683,17707,17713,17729,17737,17747,17749,17761,17783,17789,17791,17807,17827,17837,17839,17851,17863,17881,17891,17903,17909,17911,17921,17923,17929,17939,17957,17959,17971,17977,17981,17987,17989,18013,18041,18043,18047,18049,18059,18061,18077,18089,18097,18119,18121,18127,18131,18133,18143,18149,18169,18181,18191,18199,18211,18217,18223,18229,18233,18251,18253,18257,18269,18287,18289,18301,18307,18311,18313,18329,18341,18353,18367,18371,18379,18397,18401,18413,18427,18433,18439,18443,18451,18457,18461,18481,18493,18503,18517,18521,18523,18539,18541,18553,18583,18587,18593,18617,18637,18661,18671,18679,18691,18701,18713,18719,18731,18743,18749,18757,18773,18787,18793,18797,18803,18839,18859,18869,18899,18911,18913,18917,18919,18947,18959,18973,18979,19001,19009,19013,19031,19037,19051,19069,19073,19079,19081,19087,19121,19139,19141,19157,19163,19181,19183,19207,19211,19213,19219,19231,19237,19249,19259,19267,19273,19289,19301,19309,19319,19333,19373,19379,19381,19387,19391,19403,19417,19421,19423,19427,19429,19433,19441,19447,19457,19463,19469,19471,19477,19483,19489,19501,19507,19531,19541,19543,19553,19559,19571,19577,19583,19597,19603,19609,19661,19681,19687,19697,19699,19709,19717,19727,19739,19751,19753,19759,19763,19777,19793,19801,19813,19819,19841,19843,19853,19861,19867,19889,19891,19913,19919,19927,19937,19949,19961,19963,19973,19979,19991,19993,19997,20011,20021,20023,20029,20047,20051,20063,20071,20089,20101,20107,20113,20117,20123,20129,20143,20147,20149,20161,20173,20177,20183,20201,20219,20231,20233,20249,20261,20269,20287,20297,20323,20327,20333,20341,20347,20353,20357,20359,20369,20389,20393,20399,20407,20411,20431,20441,20443,20477,20479,20483,20507,20509,20521,20533,20543,20549,20551,20563,20593,20599,20611,20627,20639,20641,20663,20681,20693,20707,20717,20719,20731,20743,20747,20749,20753,20759,20771,20773,20789,20807,20809,20849,20857,20873,20879,20887,20897,20899,20903,20921,20929,20939,20947,20959,20963,20981,20983,21001,21011,21013,21017,21019,21023,21031,21059,21061,21067,21089,21101,21107,21121,21139,21143,21149,21157,21163,21169,21179,21187,21191,21193,21211,21221,21227,21247,21269,21277,21283,21313,21317,21319,21323,21341,21347,21377,21379,21383,21391,21397,21401,21407,21419,21433,21467,21481,21487,21491,21493,21499,21503,21517,21521,21523,21529,21557,21559,21563,21569,21577,21587,21589,21599,21601,21611,21613,21617,21647,21649,21661,21673,21683,21701,21713,21727,21737,21739,21751,21757,21767,21773,21787,21799,21803,21817,21821,21839,21841,21851,21859,21863,21871,21881,21893,21911,21929,21937,21943,21961,21977,21991,21997,22003,22013,22027,22031,22037,22039,22051,22063,22067,22073,22079,22091,22093,22109,22111,22123,22129,22133,22147,22153,22157,22159,22171,22189,22193,22229,22247,22259,22271,22273,22277,22279,22283,22291,22303,22307,22343,22349,22367,22369,22381,22391,22397,22409,22433,22441,22447,22453,22469,22481,22483,22501,22511,22531,22541,22543,22549,22567,22571,22573,22613,22619,22621,22637,22639,22643,22651,22669,22679,22691,22697,22699,22709,22717,22721,22727,22739,22741,22751,22769,22777,22783,22787,22807,22811,22817,22853,22859,22861,22871,22877,22901,22907,22921,22937,22943,22961,22963,22973,22993,23003,23011,23017,23021,23027,23029,23039,23041,23053,23057,23059,23063,23071,23081,23087,23099,23117,23131,23143,23159,23167,23173,23189,23197,23201,23203,23209,23227,23251,23269,23279,23291,23293,23297,23311,23321,23327,23333,23339,23357,23369,23371,23399,23417,23431,23447,23459,23473,23497,23509,23531,23537,23539,23549,23557,23561,23563,23567,23581,23593,23599,23603,23609,23623,23627,23629,23633,23663,23669,23671,23677,23687,23689,23719,23741,23743,23747,23753,23761,23767,23773,23789,23801,23813,23819,23827,23831,23833,23857,23869,23873,23879,23887,23893,23899,23909,23911,23917,23929,23957,23971,23977,23981,23993,24001,24007,24019,24023,24029,24043,24049,24061,24071,24077,24083,24091,24097,24103,24107,24109,24113,24121,24133,24137,24151,24169,24179,24181,24197,24203,24223,24229,24239,24247,24251,24281,24317,24329,24337,24359,24371,24373,24379,24391,24407,24413,24419,24421,24439,24443,24469,24473,24481,24499,24509,24517,24527,24533,24547,24551,24571,24593,24611,24623,24631,24659,24671,24677,24683,24691,24697,24709,24733,24749,24763,24767,24781,24793,24799,24809,24821,24841,24847,24851,24859,24877,24889,24907,24917,24919,24923,24943,24953,24967,24971,24977,24979,24989,25013,25031,25033,25037,25057,25073,25087,25097,25111,25117,25121,25127,25147,25153,25163,25169,25171,25183,25189,25219,25229,25237,25243,25247,25253,25261,25301,25303,25307,25309,25321,25339,25343,25349,25357,25367,25373,25391,25409,25411,25423,25439,25447,25453,25457,25463,25469,25471,25523,25537,25541,25561,25577,25579,25583,25589,25601,25603,25609,25621,25633,25639,25643,25657,25667,25673,25679,25693,25703,25717,25733,25741,25747,25759,25763,25771,25793,25799,25801,25819,25841,25847,25849,25867,25873,25889,25903,25913,25919,25931,25933,25939,25943,25951,25969,25981,25997,25999,26003,26017,26021,26029,26041,26053,26083,26099,26107,26111,26113,26119,26141,26153,26161,26171,26177,26183,26189,26203,26209,26227,26237,26249,26251,26261,26263,26267,26293,26297,26309,26317,26321,26339,26347,26357,26371,26387,26393,26399,26407,26417,26423,26431,26437,26449,26459,26479,26489,26497,26501,26513,26539,26557,26561,26573,26591,26597,26627,26633,26641,26647,26669,26681,26683,26687,26693,26699,26701,26711,26713,26717,26723,26729,26731,26737,26759,26777,26783,26801,26813,26821,26833,26839,26849,26861,26863,26879,26881,26891,26893,26903,26921,26927,26947,26951,26953,26959,26981,26987,26993,27011,27017,27031,27043,27059,27061,27067,27073,27077,27091,27103,27107,27109,27127,27143,27179,27191,27197,27211,27239,27241,27253,27259,27271,27277,27281,27283,27299,27329,27337,27361,27367,27397,27407,27409,27427,27431,27437,27449,27457,27479,27481,27487,27509,27527,27529,27539,27541,27551,27581,27583,27611,27617,27631,27647,27653,27673,27689,27691,27697,27701,27733,27737,27739,27743,27749,27751,27763,27767,27773,27779,27791,27793,27799,27803,27809,27817,27823,27827,27847,27851,27883,27893,27901,27917,27919,27941,27943,27947,27953,27961,27967,27983,27997,28001,28019,28027,28031,28051,28057,28069,28081,28087,28097,28099,28109,28111,28123,28151,28163,28181,28183,28201,28211,28219,28229,28277,28279,28283,28289,28297,28307,28309,28319,28349,28351,28387,28393,28403,28409,28411,28429,28433,28439,28447,28463,28477,28493,28499,28513,28517,28537,28541,28547,28549,28559,28571,28573,28579,28591,28597,28603,28607,28619,28621,28627,28631,28643,28649,28657,28661,28663,28669,28687,28697,28703,28711,28723,28729,28751,28753,28759,28771,28789,28793,28807,28813,28817,28837,28843,28859,28867,28871,28879,28901,28909,28921,28927,28933,28949,28961,28979,29009,29017,29021,29023,29027,29033,29059,29063,29077,29101,29123,29129,29131,29137,29147,29153,29167,29173,29179,29191,29201,29207,29209,29221,29231,29243,29251,29269,29287,29297,29303,29311,29327,29333,29339,29347,29363,29383,29387,29389,29399,29401,29411,29423,29429,29437,29443,29453,29473,29483,29501,29527,29531,29537,29567,29569,29573,29581,29587,29599,29611,29629,29633,29641,29663,29669,29671,29683,29717,29723,29741,29753,29759,29761,29789,29803,29819,29833,29837,29851,29863,29867,29873,29879,29881,29917,29921,29927,29947,29959,29983,29989,30011,30013,30029,30047,30059,30071,30089,30091,30097,30103,30109,30113,30119,30133,30137,30139,30161,30169,30181,30187,30197,30203,30211,30223,30241,30253,30259,30269,30271,30293,30307,30313,30319,30323,30341,30347,30367,30389,30391,30403,30427,30431,30449,30467,30469,30491,30493,30497,30509,30517,30529,30539,30553,30557,30559,30577,30593,30631,30637,30643,30649,30661,30671,30677,30689,30697,30703,30707,30713,30727,30757,30763,30773,30781,30803,30809,30817,30829,30839,30841,30851,30853,30859,30869,30871,30881,30893,30911,30931,30937,30941,30949,30971,30977,30983,31013,31019,31033,31039,31051,31063,31069,31079,31081,31091,31121,31123,31139,31147,31151,31153,31159,31177,31181,31183,31189,31193,31219,31223,31231,31237,31247,31249,31253,31259,31267,31271,31277,31307,31319,31321,31327,31333,31337,31357,31379,31387,31391,31393,31397,31469,31477,31481,31489,31511,31513,31517,31531,31541,31543,31547,31567,31573,31583,31601,31607};
int psar2[] = {147483634,221225451,368709085,516192719,811159987,958643621,253610882,401094516,696061784,138512679,285996313,728447215,23414476,170898110,465865378,908316280,350767175,498250809,940701711,235668972,383152606,825603508,120570769,563021671,152956200,447923468,595407102,890374370,37857997,332825265,365210696,660177964,102628859,250112493,987530663,135014290,577465192,19916087,314883355,757334257,199785152,347268786,84686949,232170583,527137851,674621485,559523282,444425079,739392347,886875981,181843242,624294144,771777778,509195941,951646843,394097738,836548640,984032274,426483169,721450437,868934071,606352234,638737665,933704933,81188560,376155828,408541259,850992161,588410324,735893958,30861219,473312121,63246650,505697552,948148454,243115715,685566617,275501146,570468414,160402943,897821113,45304740,782722910,930206544,372657439,667624707,110075602,700010138,994977406,142461033,437428301,322330098,912264634,207231895,797166431,92133692,534584594,419486391,566970025,894322724,336773619,74191782,516642684,959093586,106577213,549028115,286446278,728897180,171348075,318831709,761282611,203733506,498700774,646184408,531086205,268504368,415988002,710955270,153406165,595857067,743340701,628242498,923209766,365660661,955595197,693013360,282947889,20366052,610300588,52751483,495202385,790169653,380104182,822555084,117522345,707456881,2424142,34809573,772227743,657129540,804613174,542031337,689514971,984482239,131965866,869384036,901769467,196736728,344220362,639187630,671573061,966540329,114023956,408991224,883827557,178794818,768729354,506147517,96082046,391049314,833500216,275951111,308336542,603303810,45754705,488205607,78140136,520591038,405492835,700460103,142910998,290394632,27812795,175296429,617747331,355165494,502649128,240067291,387550925,830001827,157354519,452321787,599805421,894772689,337223584,779674486,369609015,812059917,254510812,876830779,24314406,761732576,351667105,89085268,531536170,973987072,563921601,448823398,743790666,186241561,628692463,776176097,218626992,103528789,840946959,168299651,315783285,610750553,53201448,200685082,643135984,938103252,85586879,380554147,265455944,412939578,855390480,362612237,805063139,247514034,837448570,164801262,902219432,934604863,229572124,377055758,672023026,114473921,704408457,999375725,146859352,589310254,474212051,211630214,359113848,654081116,801564750,96532011,538982913,423884710,308786507,898721043,783622840,226073735,521041003,963491905,553426434,848393702,438328231,733295499,765680930,60648191,503099093,650582727,945549995,388000890,535484524,977935426,715353589,190189915,632640817,927608085,75091712,844895313,139862574,287346208,24764371,909666175,57149802,794567972,384502501,826953403,269404298,711855200,39207892,481658794,776626062,924109696,809011493,546429656,431331453,21265982,201135047,233520478,675971380,970938648,118422275,413389543,560873177,298291340,183193137,625644039,68094934,395447633,542931267,722800332,870283966,492603926,935054828,524989357,967440259,262407520,409891154,704858422,294792951,737243853,474662016,622145650,359563813,391949244,129367407,571818309,456720106,604203740,899171008,46654635,784072805,668974602,816458236,996327301,143810928,586261830,881229098,28712725,766130895,356065424,683418123,453221717,748188985,190639880,780574416,960443481,107927108,402894376,992828912,172697970,320181604,615148872,205083401,647534303,89985198,384952466,269854263,417337897,39657857,482108759,629592393,72043288,367010556,809461458,841846889,284297784,579265052,726748686,169199581,464166849,906617751,791519548,233970443,676421345,708806776,3774037,446224939,331126736,921061272,363512167,658479435,575766663,903119362,640537525,230472054,525439322,967890224,115373851,557824753,180144713,65046510,212530144,392399209,982333745,277301006,162202803,194588234,932006404,79490031,374457299,964391835,406842730,849293632,144260893,291744527,586711795,29162690,619097226,914064494,61548121,503999023,241417186,388900820,126318983,716253519,11220780,43606211,781024381,665926178,813409812,255860707,550827975,698311609,878180674,910566105,205533366,647984268,237918797,680369699,975336967,302689659,892624195,630042358,72493253,514944155,104878684,842296854,727198651,759584082,54551343,497002245,939453147,86936774,151707636,299191270,36609433,626543969,921511237,953896668,248863929,838798465,723700262,166151157,51052954,346020222,788471124,263307450,725613,148209247,328078312,245365540,540332808,687816442,572718239,15169134,310136402,195038199,637489101,227423630,522390898,112325427,734645394,882129028,177096289,324579923,209481720,274252582,421736216,864187118,306638013,749088915,44056176,486507078,633990712,518892509,813859777,698761574,846245208,583663371,731147005,911016070,58499697,238368762,680819664,155655990,335525055,925459591,220426852,367910486,662877754,810361388,432681348,22615877,907517681,349968576,87386739,234870373,529837641,972288543,119772170,562223072,299641235,447124869,332026666,69444829,216928463,954346633,986732064,429182959,724150227,166601122,756535658,198986553,641437455,821306520,706208317,853691951,148659212,181044643,623495545,918462813,508397342,245815505,835750041,278200936,720651838,342971798,785422700,932906334,670324497,702709928,997677196,440128091,767480790,914964424,652382587,684768018,979735286,127218913,864637083,897022514,191989775,781924311,109277003,404244271,846695173,994178807,289146068,731596970,879080604,763982401,58949662,533785995,156105955,41007752,188491386,483458654,925909556,368360451,515844085,958294987,580614947,728098581,170549476,350418541,792869443,677771240,825254874,267705769,152607566,332476631,479960265,774927533,217378428,249763859,544731127,692214761,19567453,789371054,526789217,969240119,116723746,854141916,1625543,739043713,886527347,623945510,66396405,213880039,951298209,98781836,836200006,278650901,868585437,80839926,818258096,965741730,703159893,293094422,735545324,472963487,800316186,242767081,127668878,12570675,160054309,487407008,929857910,224825171,667276073,109726968,437079667,584563301,321981464,354366895,796817797,91785058,239268692,534235960,304039554,451523188,336424985,778875887,958744952,548679481,991130383,433581278,760933977,940803042,88286669,383253937,825704839,973188473,415639368,858090270,595508433,37959328,922861132,807762929,135115621,282599255,725050157,20017418,347370117,937304653,707108247,2075508,149559142,444526410,886977312,34460939,919362743,214330004,246715435,458969931,196388094,638838996,523740793,556126224,998577126,735995289,620897086,768380720,63347981,505798883,95733412,538184314,275602477,423086111,718053379,750438810,192889705,635340607,930307875,372758770,520242404,257660567,405144201,585013266,469915063,59849592,387202291,682169559,124620454,9522251,157005885,599456787,41907682,484358584,549129446,991580348,23965772,318933040,908867576,646285739,236220268,121122065,448474764,743442032,890925666,185892927,955696528,840598325,283049220,430532854,610401919,52852814,495303716,527689147,265107310,297492741,592460009,804714505,247165400,689616302,132067197,722001733,164452628,459419896,606903530,491805327,934256229,229223490,376707124,819158026,441477986,883928888,31412515,326379783,653732482,801216116,96183377,981085181,128568808,571019710,865986978,783274206,225725101,668176003,963143271,553077800,290495963,650234093,830103158,977586792,420037687,715004955,862488589,157455850,304939484,42357647,74743078,517193980,812161248,402095777,139513940,581964842,56801168,351768436,499252070,941702972,153957461,448924729,38859258,776277428,218728323,661179225,251113754,693564656,578466453,873433721,315884616,463368250,905819152,200786413,643237315,790720949,528139112,675622746,855491811,297942706,772779039,67746300,952648104,985033535,49804390,492255292,967091625,262058886,589411585,179346114,621797016,916764284,359215179,391600610,834051512,276502407,13920570,161404204,898822374,783724171,373658700,111076863,258560497,995978667,585913196,470814993,208233156,978036757,125520384,420487652,10422181,452873083,747840351,337774880,665127579,402545742,844996644,287447539,434931173,877382075,614800238,499702035,647185669,384603832,827054734,269505629,711956531,301891060,744341962,481760125,924211027,71694654,514145556,956596458,399047353,136465516,726400052,496203646,938654548,560974508,708458142,35810834,330778102,920712638,658130801,870385297,460319826,787672525,82639786,230123420,967541590,409992485,557476119,999927021,294894282,622246981,212181510,97083307,424436006,604305071,46755966,194239600,79141397,521592299,259010462,406494096,143912259,291395893,733846795,471264958,503650389,798617657,568421251,715904885,895773950,43257577,780675747,928159381,665577544,140413870,435381138,582864772,877832040,467766569,647635634,90086529,532537431,680021065,564922862,744791927,334726456,629693724,72144619,284399115,431882749,169300912,316784546,759235448,54202709,496653611,939104513,529039042,971489944,266457205,151359002,593809904,183744433,68646230,363613498,395998929,280900726,18318889,788122490,230573385,115475182,557926084,705409718,327729678,917664214,245016906,982435076,424885971,457271402,752238670,899722304,342173199,79591362,669525898,111976793,406944061,849394963,61649452,94034883,831453053,978936687,863838484,601256647,748740281,928609346,76092973,403445672,173249266,500601965,943052867,122921925,450274624,892725526,40209153,367561852,662529120,104980015,252463649,989881819,579816348,317234511,759685413,202136308,792070844,87038105,529489007,676972641,414390804,561874438,446776235,741743503,184194398,626645300,774128934,659030731,953997999,986383430,313736122,608703390,51154285,525990618,820957886,410892415,853343317,148310578,738245114,33212375,65597806,508048708,803015976,835401407,720303204,15270465,162754099,375008595,669975863,439779457,882230359,324681254,209583051,94484848,126870279,569321181,864288449,11772076,306739344,634092043,76542938,961444742,551379271,993830173,288797434,173699231,321182865,206084662,418339158,598208223,745691857,188142752,810462719,842848150,285299045,22717208,907619012,350069907,497553541,792520809,382455338,119873501,562324403,4775298,774578899,806964330,249415225,544382493,134317022,19218819,346571518,83989681,231473315,968891485,116375112,411342380,853793282,328629608,771080510,66047771,98433202,393400470,540884104,835851372,868236803,310687698,195589495,965393096,702811259,145262154,735196690,472614853,620098487,832352983,127320244,569771146,717254780,602156577,897123845,929509276,371960171,879181935,764083732,354018261,796469163,533887326,681370960,976338228,451174554,188592717,778527253,958396318,105879945,843298115,875683546,170650807,318134441,203036238,645487140,825356205,267807100,857741636,152708897,742643433,37610694,480061596,69996125,512447027,954897929,839799726,282250621,577217889,19668784,462119686,52054215,379406914,674374182,149210508,444177776,329079573,476563207,213981370,656432272,803915906,541334069,426235866,573719500,868686768,343523094,785973996,998228492,440679387,735646655,325581184,62999347,947901151,390352046,537835680,602606542,750090176,192541071,487508339,634991973,814861038,699762835,847246469,289697364,27115527,617050063,386853657,271755454,714206356,41559048,484009950,778977218,811362649,253813544,548780812,433682609,23617138,466068040,350969837,645937105,88388000,973289804,415740699,300642496,448126130,627995195,102831521,397798789,545282423,282700586,610053285,199987814,494955082,527340513,822307781,969791415,412242310,34562270,477013172,509398603,951849505,394300400,131718563,574169465,721653099,459071262,606554896,901522164,49005791,671325758,818809392,113776653,556227555,998678457,883580254,326031149,358416580,95834743,980736547,423187442,13121971,308089239,962794637,995180068,880081865,322532760,617500028,59950923,207434557,92336354,534787256,419689053,599558118,747041752,484459915,74394444,696714411,844198045,729099842,171550737,466518005,908968907,236321599,383805233,268707030,711157932,6125193,891026997,480961526,923412428,808314225,103281486,545732388,430634185,873085087,20568714,905470518,790372315,85339576,117725007,560175909,740044974,182495869,329979503,67397666,657332202,984684901,427135796,934357560,81841187,146612049,294095683,916415650,358866545,506350179,243768342,128670139,276153773,718604675,13571936,603506472,225826432,668277334,815760968,553179131,143113660,438080928,880531830,470466359,765433627,650335424,977688123,862589920,337426246,632393514,74844409,517295311,107229840,402197108,549680742,729549807,614451604,761935238,499353401,89287930,826706100,974189734,269156995,711607897,743993328,628895125,251215085,841149621,905920483,53404110,348371378,823207711,118174972,265658606,560625874,593011305,330429468,215331265,362814899,247716696,427585761,575069395,639840257,229774786,852094753,442029282,736996550,179447445,621898347,654283778,949251046,539185575,424087372,866538274,308989169,603956437,78792763,373760031,701112730,848596364,733498161,175949056,470916324,913367226,945752657,273105349,10523512,600458048,337876211,697614341,140065236,877483406,319934301,762385203,909868837,352319732,532188797,974639699,122123326,7025123,449476025,514246887,661730521,399148684,989083220,168952278,611403180,201337709,643788611,381206774,151010368,625846701,363264864,510748498,248166661,395650295,280552092,575519360,17970255,492806588,787773856,935257490,820159287,147511979,884930149,32413776,769831946,917315580,212282841,687119174,866988239,784275467,79242728,669177264,111628159,406595427,291497224,733948126,323882655,208784452,93686249,536137151,831104419,421038948,43358908,190842542,370711607,403097038,140515201,582966103,467867900,352769697,385155128,827606030,122573291,597409624,892376892,777278689,219729584,367213218,809664120,252115015,431984080,21918609,644238576,791722210,856493072,446427601,888878503,183845764,658682097,953649365,838551162,608354756,83191082,378158350,968092886,705511049,852994683,32863741,180347375,65249172,950150976,457372733,604856367,899823635,342274530,227176327,669627229,112078124,702012660,144463555,439430823,586914457,29365352,799168953,94136214,568972547,306390710,748841612,191292507,223677938,518645206,961096108,403547003,551030637,435932434,878383336,615801499,763285133,500703296,943154198,417990524,712957792,630245020,925212288,72695915,515146817,137466777,284950411,54754005,349721273,792172175,939655809,234623070,677073972,446877566,889328468,479262997,774230265,921713899,428935656,871386558,461321087,641190152,526091949,673575583,410993746,558477380,295895543,738346445,328280974,623248242,213182771,98084568,720404535,162855430,195240861,490208129,407495357,702462625,849946259,734848056,472266219,62200748,357168016,947102552,832004349,126971610,159357041,601807943,781677008,224127903,814062439,109029700,551480602,993931504,583866033,26316928,763735098,648636895,796120529,238571424,681022326,860891391,450825920,893276822,335727717,220629514,958047684,105531311,547982213,875334912,170302173,612753075,55203970,497654872,382556669,709909368,299843897,742294799,479712962,69647491,397000190,691967458,724352889,166803784,494156483,231574646,821509182,558927345,443829142,591312776,33763671,918665475,803567272,458272663,753239931,195690826,785625362,80592623,523043525,670527159,965494427,292847119,177748916,620199818,210134347,652585249,95036144,390003412,717356111,864839745,159807006,307290640,77094234,372061502,814512404,256963299,289348730,501603226,944054128,239021389,681472291,566374088,8824983,483661316,778628584,368563113,663530381,253464910,695915812,138366707,433333975,645588471,793072105,530490268,415392065,5326594,742744764,332679293,102482887,544933789,429835586,724802854,757188285,52155546,494606448,642090082,706860944,739246375,919115440,66599067,951500871,393951766,688919034,163755360,901173530,343624425,786075327,228526222,818460758,555878921,440780718,473166149,210584312,242969743,422838808,455224239,192642402,225027833,667478735,847347800,289798695,879733231,322184126,502053191,976889524,714307687,861791321,304242216,599209484,746693118,41660379,926562183,74045810,811463980,958947614,401398509,23718469,466169371,613653005,908620273,235972965,825907501,563325664,153260193,775580160,923063794,660481957,987834656,20220080,315187348,462670982,757638250,84990942,232474576,527441844,969892746,559827275,297245438,444729072,656983568,951950836,164205325,311688959,49107122,196590756,523943455,818910723,146263415,588714317,621099748,358517911,506001545,800968813,275805139,930510537,372961432,667928700,110379595,142765026,437732294,912568627,649986790,682372221,304692181,747143083,894626717,106881206,991783010,729201173,56553865,204037499,499004767,531390198,973841100,596161060,923513759,70997386,955899190,398350085,693317353,283251882,578219150,168153679,610604581,348022744,495506378,380408175,707760874,445179037,477564468,657433533,689818964,984786232,427237127,869688029,17171656,459622558,754589826,902073460,966844322,114327949,179098811,621549713,769033347,64000608,506451510,538836941,833804209,718706006,751091437,930960502,963345933,258313194,700764096,290698625,733149527,28116788,470567690,913018592,355469487,945404023,240371284,830305820,125273081,157658512,337527577,927462113,369913008,664880276,549782073,139716602,319585667,467069301,204487464,794422000,89389261,531840163,449127391,891578293,628996456,218930985,513898253,956349155,841250952,873636383,85890872,380858140,413243571,35563531,625498067,510399864,805367132,247818027,837752563,575170726,17621621,50007052,787425222,229876117,377359751,114777914,999679718,884581515,916966946,359417841,801868743,129221435,866639605,309090500,899025036,226377728,521344996,963795898,111279525,553730427,291148590,438632224,176050387,765984923,208435818,650886720,388304883,535788517,863141216,600559379,748043013,632944810,927912078,370362973,960297509,697715672,582617469,615002900,499904697,794871965,384806494,122224657,564675559,7126454,481962787,776930055,809315486,989184551,21569975,758988145,348922674,86340837,971242641,118726268,446078967,888529869,773431666,510849829,395751626,543235260,838202528,985686162,870587959,313038854,608006122,197940651,492907919,737547846,32515107,179998741,474966009,622449643,359867806,244769603,687220505,129671400,162056831,457024099,899475001,341925896,784376798,374311327,816762229,471467620,798820319,93787580,536238482,683722116,568623913,11074808,453525710,895976612,190943873,223329304,845649271,730551068,878034702,205387394,942805564,385256459,302543687,72347281,367314549,514798183,809765451,957249085,252216346,284601777,579569045,22019940,464470842,54405371,234274436,119176233,266659867,363816160,658783428,806267062,101234323,871037924,313488819,755939721,903423355,230776047,525743315,558128746,579641,65350503,392703202,425088633,867539535,604957698,489859495,637343129,79794024,964695828,176950317,619401219,914368487,356819382,799270284,831655715,126622976,274106610,43910204,338877472,781328374,223779269,141066497,878484667,205837359,648288261,238222790,680673692,123124587,335379083,630346351,515248148,400149945,547633579,727502644,874986278,317437173,612404441,497306238,824658937,972142571,414593466,709560734,626847962,511749759,954200661,839102458,134069719,903873320,673676914,558578711,1029606,148513240,33415037,98185899,688120435,983087703,425538598,310440395,457924029,785276728,227727623,522694891,965145793,407596688,882433021,62302079,209785713,652236615,94687510,422040209,159458372,601909274,749392908,44360169,634294705,76745600,519196502,289000096,468869161,911320063,501254592,238672755,681123657,713509088,335829048,925763584,105632642,548083544,695567178,580468975,875436243,22919870,645239837,235174366,562527065,69748822,217232456,659683358,987036057,282003318,724454220,166905115,756839651,494257814,84192343,411545042,853995944,148963205,296446839,591414107,181348636,361217701,508701335,393603132,278504929,720955831,48308523,343275791,785726693,228177588,670628490,818112124,260563019,145464816,882882986,357719312,242621109,569973808,864941076,307391971,454875605,634744670,782228304,519646467,552031898,846999166,59253655,206737289,944155459,829057256,976540890,746344484,188795379,368664444,958598980,696017143,843500777,728402574,350722534,793173436,940657070,120526128,595362461,332780624,480264258,365166055,250067852,577420551,314838714,199740511,642191413,789675047,527093210,674576844,117027739,854445909,181798601,329282235,214184032,656634934,951602202,394053097,541536731,311340325,376111187,523594821,818562089,966045723,703463886,850947520,30816578,915718382,505652911,127972871,275456505,717907407,12874668,160358302,897776472,340227367,815063700,699965497,437383660,27318189,912219993,354670888,797121790,239572685,534539953,861892652,9376279,304343547,189245344,516598043,664081677,548983474,991434376,286401637,433885271,613754336,498656133,383557930,415943361,710910629,300845158,628197857,923165125,808066922,840452353,282903248,725354150,20321411,610255947,52706842,347674110,822510443,707412240,444830403,477215834,772183102,919666736,99535794,247019428,131921225,344175721,639142989,81593884,851397485,326233811,96037405,833455575,423390104,308291901,45710064,930611868,373062763,257964560,142866357,585317259,175251788,355120853,387506284,829957186,124924447,567375349,222080740,696917073,434335236,646589732,531491529,678975163,973942431,121426058,186196920,71098717,103484148,545935050,168255010,758189546,53156807,380509506,822960408,855345839,182698531,477665799,920116701,67600328,510051230,17272987,344625686,492109320,671978385,114429280,441781979,589265613,359069207,654036475,801520109,243971004,128872801,571323703,456225500,193643663,783578199,226029094,405898159,290799956,880734492,618152655,650538086,600210745,42661640,190145274,632596176,927563444,812465241,844850672,139817933,287301567,582268835,729752469,24719730,614654266,57105161,794523331,236974226,679425128,826908762,269359657,711810559,154261454,39163251,481614153,251417747,988835917,136319544,873737714,316188609,201090406,643541308,85992203,118377634,560828536,3279431,837853894,312690220,755141122,492559285,640042919,377461082,967395618,704813781,589715578,474617375,622101009,64551904,359519172,391904603,571773668,161708197,46609994,489060896,111380856,258864490,996282660,586217189,28668084,650988051,798471685,420791645,863242547,453177076,190595239,75497036,960398840,107882467,845300637,287751532,172653329,320136963,615104231,647489662,384907825,532391459,974842361,302195053,597162321,482064118,71998647,399351346,284253143,726704045,169154940,464122208,906573110,349024005,381409436,676376704,823860338,708762135,593663932,888631200,331082095,658434794,985787493,870689290,18172917,198041982,82943779,672878315,231007,737649177,654936405,949903673,392354568,982289104,424739999,867190901,162158162,309641796,47059959,521896292,816863560,259314455,849248991,144216252,619052585,356470748,503954382,11176139,158659773,453627041,223430635,370914269,255816066,140717863,878136033,320586928,468070562,352972359,565226855,7677750,892579554,72448612,957350416,104834043,727154010,54506702,939408506,971793937,709212100,856695734,741597531,626499328,921466596,68950223,363917491,806368393,691270190,838753824,18622882,345975581,493459215,443131874,33066403,212935468,655386370,245320899,982739069,130222696,425189964,752542663,342477192,79895355,669829891,554731688,849698956,177051648,324535282,651887981,389306144,536789778,831757046,979240680,274207941,864142477,928913339,76396966,518847868,141167828,26069625,468520527,500905958,828258657,123225918,565676820,155611349,598062251,40513146,777931316,367865845,662833113,810316747,137669439,875087609,317538504,792374837,414694797,4629326,447080228,659334724,954301992,101785619,396752887,724105586,166556481,378810977,526294611,821261879,411196408,853647310,148614571,591065473,475967270,508352701,15574458,47959889,490410791,785378059,932861693,375312588,670279856,702665287,997632555,145116182,587567084,652337946,799821580,94788841,537239743,127174272,864592442,12076069,749494239,896977873,634396036,781879670,76846931,289101427,436585061,321486858,206388655,943806825,271159517,156061314,188446745,925864915,73348542,958250346,400701241,138119404,580570306,612955737,497857534,792824802,825210233,120177494,447530193,595013827,332431990,922366526,217333787,807268323,544686486,429588283,756940982,84293674,674228210,116679105,444031804,623900869,656286300,98737195,541188097,278606260,310991691,605958959,48409854,195893488,80795285,965697089,260664350,703115252,145566147,30467944,177951578,357820643,505304277,390206074,832656976,127624237,160009668,602460570,897427838,44911465,929813269,257165961,552133229,206838620,534191319,419093116,303994913,451478547,746445815,893929449,188896710,778831246,663733043,958700311,613405702,55856597,383209296,530692930,415594727,153012890,595463792,480365589,250169183,840103719,282554614,725005516,904874581,789776378,937260012,264612704,2030867,476867200,214285363,361768997,804219899,131572591,426539859,574023493,523696152,966147054,113630681,293499746,440983380,735950648,325885177,653237876,390656039,275557836,718008738,865492372,602910535,192845064,487812332,930263234,815165031,962648665,700066828,27419520,617354056,59804951,354772219,829608552,124575813,567026715,221732106,664183008,811666642,549084805,991535707,761339301,203790196,236175627,416044692,858495594,185848286,333331920,70750083,545586416,283004579,872939115,315390010,610357278,52808173,200291807,937709977,85193604,970095408,265062669,412546303,707513571,297448100,34866263,477317165,362218962,689571661,721957092,606858889,786727954,376662483,819113385,998982450,588916979,883884247,31367874,473818776,801171475,570975069,898327768,635745931,520647728,668131362,963098630,995484061,732902224,175353119,617804021,60254916,387607615,272509412,419993046,484763908,812116607,844502038,24371096,909272900,941658331,711461925,596363722,218683682,661134584,808618218,546036381,135970910,430938178,578421812,873389080,905774511,790676308,233127203,528094471,970545373,2930797,297898065,445381699,740348967,952603463,395054358,542537992,984988894,722407057,869890691,82145180,704465147,851948781,146916042,589366944,179301473,621752375,64203270,244072335,128974132,13875929,456326831,46261360,341228628,488712262,258515856,143417653,438384921,880835823,470770352,913221254,355672149,93090312,240573946,683024848,567926645,632697507,665082938,107533833,402501101,287402898,877337434,319788329,204690126,499657394,942108296,974493727,416944622,301846419,39264582,481715484,924166386,514100915,956551817,399002712,693969980,841453614,136420875,726355411,611257208,906224476,938609907,265962599,3380762,150864396,330733461,773184363,248020689,690471591,427889754,17824283,312791551,525046047,179751438,64653235,654587771,276907731,161809528,309293162,751744064,636645861,816514926,258965821,701416723,848900357,176253049,471220317,388507545,683474813,273409342,600762041,338180204,928114740,665532903,107983798,140369229,435336497,910172830,532492790,859845489,744747286,334681815,399452677,284354474,726805376,169256271,759190807,201641702,86543499,856347100,36216158,68601589,363568857,395954288,280856085,723306987,460725150,345626947,820463280,262914175,557881443,147815972,475168671,360070468,687423167,424841330,572324964,867292232,342128558,79546721,111932152,406899420,849350322,996833956,734252119,504055713,831408412,978892046,273859307,748695640,928564705,960950136,698368299,730753730,173204625,468171893,910622795,385459121,827910023,565328186,7779081,155262715,40164512,482615414,694869910,432288073,22222602,464673504,759640772,202091667,792026203,741698862,889182496,184149757,331633391,216535188,543887887,838855155,281306050,871240586,608658749,51109644,378462343,705815042,853298676,738200473,918069538,508004067,950454969,245422230,687873132,130324027,277807661,112382117,144767548,439734816,914571149,94440207,241923841,536891109,979342011,864243808,11727435,454178337,339080134,223981931,666432833,961400101,993785532,731203695,173654590,616105492,648490923,385909086,418294517,598163582,188098111,630549013,515450810,810418078,400352607,22672567,465123469,612607103,939959802,562279762,4730657,152214291,479566990,922017892,101886950,134272381,871690551,314141446,199043243,346526877,788977779,83945040,673879576,1232268,886134072,66003130,213486764,508454032,540839463,835806731,425741260,310643057,195544854,407799350,587668415,177602944,472570212,620053846,62504741,684824708,569726505,159661034,897079204,339530099,781981001,224431896,256817327,699268229,26620921,764039091,648940888,796424522,533842685,681326319,976293587,893580815,188548076,73449873,663384409,958351677,285704369,875638905,613057068,645442499,825311564,267762459,710213361,300147890,37566053,480016955,69951484,512402386,397304183,134722346,609558679,346976842,936911378,231878639,116780436,34067664,361420363,656387631,541289428,868642127,311093022,523347518,965798420,555732949,998183851,620503811,505405608,652889242,947856510,390307405,832758307,980241941,717660104,865143738,160110999,602561901,45012796,192496430,634947332,257267292,584619991,27070886,354423585,239325382,829259918,714161715,156612610,894030780,778932577,926416211,106285269,253768903,991187073,138670700,876088870,203441562,645892464,120728790,415696058,563179692,5630587,627950554,70401449,512852351,840205050,282655945,315041376,199943173,379812238,527295872,969746774,412197669,707164937,739550368,624452165,919419433,66903060,394255759,574124824,228830215,113732012,556182914,588568345,653339207,800822841,685724638,128175533,13077330,455528232,750495500,897979134,77848192,290102688,880037224,649840818,92291713,304546209,41964372,189448006,516800705,811767973,254218868,139120665,729055201,351375161,498858795,941309697,563629657,890982356,38465983,775884153,923367787,660785950,873040446,20524073,85294935,527745837,560131268,740000333,182451228,657287561,837156626,984640260,427091155,722058423,81796546,376763814,524247448,819214716,261665611,409149245,294051042,589018310,31469205,473920107,358821904,506305538,948756440,243723701,686174603,276109132,718560034,13527295,488363628,783330896,143069019,880487189,470421718,650290783,797774417,420094377,567578011,862545279,304996174,894930710,337381605,517250670,549636101,844603369,171956061,761890597,56857858,531694191,974145093,859046890,743948687,186399582,923817752,71301379,808719549,956203183,841104980,905875842,790777639,118130331,265613965,592966664,330384827,920319363,657737526,197344714,344828348,639795616,82246511,672181047,409599210,557082844,294501007,506755503,654239137,308944528,751395430,488813593,931264495,78748122,406100821,701068089,143518984,733453520,913322585,945708016,125577074,568027976,600413407,895380675,370217001,665184269,107635164,255118798,992536968,877438765,24922392,467373294,352275091,794725993,237176888,532144156,417045953,564529587,6980482,301947750,186849547,629300449,219234978,514202246,661685880,104136775,431489474,168907637,611358539,201293068,86194865,528645767,150965727,298449361,740900263,625802060,953154759,248122020,280507451,722958353,17925614,492761947,935212849,115081907,705016443,999983711,589918240,212238200,802172736,687074533,129525428,571976330,751845395,636747192,964099891,176354380,766288916,61256177,208739811,503707079,946157981,863445209,158412470,190797901,960601502,582921462,25372357,172855991,615306893,352725056,795175958,827561389,270012284,712463186,597364983,334783146,777234048,924717682,809619479,547037642,431939439,21873968,349226667,676579366,413997529,856448431,446382960,626252025,68702920,511153822,101088351,280957416,755793749,50761010,198244644,935662814,83146441,820564611,705466408,147917303,737851839,180302734,917720904,392557230,129975393,457328092,374615320,669582588,112033483,324287979,471771613,766738881,356673410,799124312,684026109,568927906,896280605,191247866,781182402,403502362,845953264,993436898,878338695,385560452,828011354,155364046,40265843,482716745,630200379,694971241,727356672,907225737,939611168,234578429,266963860,151865657,446832925,889283827,331734722,479218356,133923747,428891015,871341917,346178243,231080040,883634,443334536,65654496,213138130,393007195,720359894,605261691,490163488,817516187,964999821,407450716,849901618,292352513,587319781,29770676,62156107,357123375,504607009,126926969,716861505,601763302,44214197,781632367,224083262,814017798,698919595,26272287,911174091,353624986,91043149,238526783,860846750,893232181,335683076,778133978,73101239,400453938,842904840,317741166,940061133,87544760,972446564,742250158,37217419,364570118,691922817,839406451,461726411,609210045,904177313,789079110,379013639,263915436,1333599,33719030,328686298,476169932,803522631,983391696,785580721,228031616,670482518,112933413,997835217,735253380,177704275,62606072,652540608,94991503,389958771,832409673,864795104,77049593,519500495,256918658,846853194,469173154,911624056,501558585,386460382,123878545,271362179,8780342,156263976,598714878,336133041,483616675,221034838,105936635,433289334,908125667,350576562,645543830,235478359,857798326,300249221,742700123,954954619,397405514,429790945,872241847,757143644,642045441,84496336,821914506,969398140,706816303,919070799,66554426,246423491,836358027,131325288,278808922,721259824,48612516,343579784,491063418,933514320,228481581,145768809,440736077,30670606,473121508,210539671,358023305,652990573,95441468,685376004,980343272,422794167,635048663,519950460,667434094,109884989,552335891,847303159,322139485,944459452,534393981,829361249,976844883,271812144,581222933,171157462,466124730,56059259,678379226,825862860,120830121,153215552,890633722,38117349,333084617,807920950,250371845,987790015,315142707,757593609};

ll mdpw(ll a,ll b){
  ll r = M1;
  while(b){
    if(b&1)r=MR(r*a);
    a=MR(a*a);
    b>>=1;
  }
  return r;
}

void check(ll &ans, int i){
  bool ex = false;
  int p = ps[i];
  REP(i,n){
    st[i] = 0;
    ex |= a[i]%p==0;
    while(a[i]%p==0)a[i]/=p,st[i]++;
  }
  if(!ex)return;
  sort(st,st+n,greater<int>());
  int cnt = 0;
  REP(i,k)cnt += st[i];
  ans=MR(ans*mdpw(psar2[i],cnt));
}

int main(){
  scanf("%d%d",&n,&k);
  REP(i,n)scanf("%d",&a[i]);
  ll ans = M1;
  REP(i,3401){
    check(ans,i);
  }
  map<int,int> M;
  REP(i,n)if(a[i]>1)M[a[i]]++;
  for(pii P: M){
    int cnt = min(P.second,k);
    ans=MR(ans*mdpw(MR(P.first*R2),cnt));
  }
  printf("%lld\n",MR(ans));
  return 0;
}
0