A. Queries

Codeforces
IDCF10074A
Time2000ms
Memory64MB
Difficulty
Mathematicians are interesting (sometimes, I would say, even crazy) people. For example, my friend, a mathematician, thinks that it is very fun to play with a sequence of integer numbers. He writes the sequence in a row. If he wants he increases one number of the sequence, sometimes it is more interesting to decrease it (do you know why?..) And he likes to add the numbers in the interval [l;r]. But showing that he is really cool he adds only numbers which are equal some mod (modulo m). Guess what he asked me, when he knew that I am a programmer? Yep, indeed, he asked me to write a program which could process these queries (n is the length of the sequence): You have to output the number after the increase. You have to output the number after the decrease. The first line of each test case contains the number of elements of the sequence n and the number m. (1 ≤ n ≤ 10000) (1 ≤ m ≤ 10) The second line contains n initial numbers of the sequence. (0 ≤ number ≤ 1000000000) The third line of each test case contains the number of queries q (1 ≤ q ≤ 10000). The following q lines contains the queries (one query per line). Output q lines - the answers to the queries. ## Input The first line of each test case contains the number of elements of the sequence n and the number m. (1 ≤ n ≤ 10000) (1 ≤ m ≤ 10)The second line contains n initial numbers of the sequence. (0 ≤ number ≤ 1000000000)The third line of each test case contains the number of queries q (1 ≤ q ≤ 10000).The following q lines contains the queries (one query per line). ## Output Output q lines - the answers to the queries. [samples]
API Response (JSON)
{
  "problem": {
    "name": "A. Queries",
    "description": {
      "content": "Mathematicians are interesting (sometimes, I would say, even crazy) people. For example, my friend, a mathematician, thinks that it is very fun to play with a sequence of integer numbers. He writes th",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 65536
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10074A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Mathematicians are interesting (sometimes, I would say, even crazy) people. For example, my friend, a mathematician, thinks that it is very fun to play with a sequence of integer numbers. He writes th...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments