{"problem":{"name":"G. Repeat it","description":{"content":"Jad has bought a new computer, a really weird computer!! Every time he copies some number from the screen and pastes it, the computer pastes it many times instead of once! Jad tested his computer ma","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":65536},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10106G"},"statements":[{"statement_type":"Markdown","content":"Jad has bought a new computer, a really weird computer!!\n\nEvery time he copies some number from the screen and pastes it, the computer pastes it many times instead of once!\n\nJad tested his computer many times, and now he knows how many times the computer will paste each copied number.\n\nFor example, In case the new computer repeated each copied number 4 times. When Jad copies the number 31 and pastes it, the number that appears on the screen would be 31313131.\n\nGiven N the number that Jad copied, and M the number of times the new computer is pasting each copied number. you have to print the number that will appear on the screen.\n\nSince the number might be very big, you are asked to print it modulo 1000000007.\n\nThe first line of the input consists of a single integer t, the number of test cases. Each test case consists of two numbers M and N separated by a single space: \n\n(1 ≤ M ≤ 109) is the number of times the new computer pasted the number N. \n\n(0 ≤ N ≤ 109) is the number Jad had copied.\n\nFor each test case print one line, the number that will appear on the screen modulo 1000000007.\n\n## Input\n\nThe first line of the input consists of a single integer t, the number of test cases. Each test case consists of two numbers M and N separated by a single space: (1 ≤ M ≤ 109) is the number of times the new computer pasted the number N. (0 ≤ N ≤ 109) is the number Jad had copied.\n\n## Output\n\nFor each test case print one line, the number that will appear on the screen modulo 1000000007.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ Q \\in \\mathbb{Z} $ be the number of queries.  \nLet $ D_k $ be the document version at step $ k $, with $ D_0 = \\emptyset $.  \nEach document $ D_k $ is a sequence of integers (sentences), ordered from beginning to end.  \n\n**Constraints**  \n1. $ 1 \\le Q \\le 10^5 $  \n2. Each query is one of the following:  \n   - **A x**: Append integer $ x $ to the end of $ D_{k-1} $, resulting in $ D_k $.  \n   - **E**: Remove the first sentence from $ D_{k-1} $, resulting in $ D_k $.  \n   - **C**: Copy $ D_{k-1} $ to create $ D_k $ (no change to content).  \n\n**Objective**  \nFor each query of type **E**, output the integer removed from the beginning of the document.  \nFor all other queries, update the document state accordingly.  \nThe document version index $ k $ increments by 1 after each query.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10106G","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}