This page is still under construction.

Parts of this page are still being built. What you see may change.

Three Kinds of Sums

Time limit1sMemory limit256 MB

Summary
For each data set with N, print the sums of the first N positive integers, the first N odd integers, and the first N even integers.
Level

Easy1 of 10

Topics
Math
Solved
No attempts yet

Problem

Given a positive integer NN, compute three sums: the sum of the first NN positive integers, the sum of the first NN odd integers, and the sum of the first NN even integers.

The input holds several such data sets. The data sets are independent, and every one is processed the same way.

Input

The first line contains the number of data sets PP. (1≤P≤100001 \le P \le 10000)

Each of the next PP lines contains one data set: the data set number KK, a single space, and an integer NN. (1≤N≤100001 \le N \le 10000)

Output

Print one line for each data set. Each line contains the data set number KK, a single space, then three integers S1S_1, S2S_2 and S3S_3 separated by single spaces.

  • S1S_1 is the sum of the first NN positive integers.
  • S2S_2 is the sum of the first NN odd integers.
  • S3S_3 is the sum of the first NN even integers.

The output lines follow the order of the data sets in the input.

Examples5

  1. Example 1

    Input
    3
    1 1
    2 10
    3 1001
    
    Expected output
    1 1 1 2
    2 55 100 110
    3 501501 1002001 1003002
    
  2. Example 2

    Input
    1
    1 1
    
    Expected output
    1 1 1 2
    
  3. Example 3

    Input
    1
    1 10000
    
    Expected output
    1 50005000 100000000 100010000
    
  4. Example 4

    Input
    4
    1 1
    2 2
    3 3
    4 4
    
    Expected output
    1 1 1 2
    2 3 4 6
    3 6 9 12
    4 10 16 20
    
  5. Example 5

    Input
    6
    1 10
    2 100
    3 1000
    4 10000
    5 1
    6 9999
    
    Expected output
    1 55 100 110
    2 5050 10000 10100
    3 500500 1000000 1001000
    4 50005000 100000000 100010000
    5 1 1 2
    6 49995000 99980001 99990000