Istiak is learning about arithmetic progressions. Today, he wrote an arithmetic sequence on a piece of paper. Istiak was very happy that he managed to write an arithmetic sequence and went out for lunch.
Istiak's friend Rafsan likes to irritate him by playing silly pranks on him. This time, he could have chosen one element of Istiak's sequence and changed it. When Istiak came back, he was devastated to see his sequence ruined — it became a sequence $a_1, a_2, \ldots, a_N$ (possibly identical to the original sequence, if Rafsan did not change anything, in which case Istiak is just overreacting). Help him recover the original sequence.
Formally, you have to find an arithmetic sequence $b_1, b_2, \ldots, b_N$ which differs from $a$ in at most one position. $b$ is said to be an arithmetic sequence if there is a real number $d$ such that $b_i - b_{i-1} = d$ for each $i$ ($2 \le i \le N$). If there are multiple valid solutions, you may find any one.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains a single integer $N$.
- The second line contains $N$ space-separated integers $a_1, a_2, \ldots, a_N$.

-----Output-----
For each test case, print a single line containing $N$ space-separated integers $b_1, b_2, \ldots, b_N$. It is guaranteed that a valid solution exists.

-----Constraints-----
- $4 \le N \le 10^5$
- $|a_i| \le 10^9$ for each valid $i$
- the sum of $N$ over all test cases does not exceed $5 \cdot 10^5$

-----Example Input-----
3
4
1 3 10 7
5
-10 -5 0 5 10
4
2 2 2 10

-----Example Output-----
1 3 5 7
-10 -5 0 5 10
2 2 2 2

-----Explanation-----
Example case 1: Rafsan changed the third element from $5$ to $10$.
Example case 2: No elements were changed.
Example case 3: Rafsan changed the fourth element from $2$ to $10$.

Difficulty: interview

Starter code:

Solutions:
# cook your dish here
test_cases = int(input())
for i in range(test_cases):
 no_of_elements = int(input())
 sequence = list(map(int, input().split()))
 d1 = sequence[1] - sequence[0]
 d2 = sequence[2] - sequence[1]
 d3 = (sequence[3] - sequence[0])/3
 d4 = (sequence[3] - sequence[1])/2
 d5 = (sequence[2] - sequence[0])/2

 if (d2 == d4):
  d = d2

 elif(d3 == d5):
  d = d3

 elif(d1 == d3):
  d = d1

 elif(d1 == d5):
  d = d1

 if (d == d1):
  for i in range(no_of_elements):
   sequence[i] = int(sequence[0] + i*d)
 else:
  for i in range(no_of_elements):
   sequence[i] = int(sequence[-1] - ((no_of_elements - i - 1)*d))

 for i in sequence:
  print(i, end=" ")

 print('\n')




from statistics import mode
t=int(input())
for _ in range(t):
 n=int(input())
 l=list(map(int,input().split()))
 ll=len(l)
 diff=list()
 if(ll==4):
  diff.append(((l[3]-l[0])//3))
 for i in range(ll-1):
  diff.append(l[i+1]-l[i])
 x=mode(diff)
 if(l[0]-l[1]!=x and l[2]-l[1]==x):
  l[0]=l[1]-x
 for i in range(ll-1):
  if(l[i+1]-l[i]!=x):
   l[i+1]=l[i]+x
   
 for i in range(ll):
  print(l[i],end=" ")
 print()

from collections import Counter
def new_seq(l,d,x):
 new=[x]
 for i in range(len(l)-1):
  t=new[-1]+d
  new.append(t)
 return new
for _ in range(int(input())):
 n=int(input())
 l=list(map(int,input().split()))
 aux=[]
 for i in range(n-1):
  aux.append(l[i+1]-l[i])
 aux_1=Counter(aux)
 aux=list(set(aux))
 if len(aux)>1 and len(aux)==3:
  a,b,c=aux[0],aux[1],aux[2]
  if a+b==(2*c):
   t_1=new_seq(l,c,l[0])
   print(*t_1)
  elif a+c==(2*b):
   t_1=new_seq(l,b,l[0])
   print(*t_1)
  else:
   t_1=new_seq(l,a,l[0])
   print(*t_1)
 elif len(aux)==2:
  t_2=aux_1.most_common(1)[0][0]
  if l[0]-l[1]!=t_2:
   print(*new_seq(l,t_2,l[1]-t_2))
  else:
   print(*new_seq(l,t_2,l[0]))
 else:
  print(*l)


t=int(input())
while(t>0):
 n=int(input())
 l=list(map(int,input().split()))
 x=l[1]-l[0]
 if(l[2]-l[1]==l[3]-l[2])and(l[2]-l[1]!=x):
  l[0]=-l[2]+2*l[1]
 elif(l[2]-l[1]!=x)and(l[3]-l[2]!=l[2]-l[1])and(l[3]-l[2]!=x):
  y=l[3]-l[0]
  y//=3
  if(x==y):
   l[2]=l[1]+x
  else:
   l[1]=l[0]+y
 else:
  for i in range(2,n):
   if(l[i]!=l[i-1]+x):
    l[i]=l[i-1]+x
    break
 print(*l)
 t-=1

# cook your dish here
for j in range(int(input())):
 n=int(input())
 x=list(map(int,input().split()))
 w=x.copy()
 t=x.copy()
 d=x[1]-x[0]
 z=[x[0],x[1]]
 for i in range(2,n):
  x[i]=x[i-1]+d
  z.append(x[i])
 e=t[-1]-t[-2]
 y=[t[-1],t[-2]]
 for i in range(n-2):
  t[n-2-i-1]=t[n-2-i]-e
  y.append(t[n-2-i-1])
 y.reverse()
 am,bm=0,0
 for i in range(n):
  if(w[i]!=y[i]):
   am+=1
   if(am>1):
    break
  if(w[i]!=z[i]):
   bm+=1
   if(bm>1):
    break
 if(am==1):
  print(*y)
 else:
  print(*z)


for j in range(int(input())):
 n=int(input())
 x=list(map(int,input().split()))
 w=x.copy()
 t=x.copy()
 d=x[1]-x[0]
 z=[x[0],x[1]]
 for i in range(2,n):
  x[i]=x[i-1]+d
  z.append(x[i])
 e=t[-1]-t[-2]
 y=[t[-1],t[-2]]
 for i in range(n-2):
  t[n-2-i-1]=t[n-2-i]-e
  y.append(t[n-2-i-1])
 y.reverse()
 am,bm=0,0
 for i in range(n):
  if(w[i]!=y[i]):
   am+=1
   if(am>1):
    break
  if(w[i]!=z[i]):
   bm+=1
   if(bm>1):
    break
 if(am==1):
  print(*y)
 else:
  print(*z)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat May 16 22:03:29 2020

@author: shailesh
"""


def findD_and_start(A):
 first = A[1] - A[0]
 second = A[2] - A[1]
 third = A[3] - A[2]
 if first == second:
  return second,A[0]
 elif third == second:
  return third,A[3] - 3*third
 else:
  return (A[3] - A[0])//3,A[0]
T = int(input())

for t in range(T):
 N = int(input())
 A = [int(i) for i in input().split()]
 d,start = findD_and_start(A)
 
 s = ''
 if d ==0:
  for i in range(N):
   s+=str(start) + ' '
 else:
  for i in range(start,start + N*d,d):
   s+= str(i) + ' '
 print(s.strip())

for _ in range(int(input())):
 n = int(input())
 a = list(map(int, input().split()))
 f = False
 d = 0
 for i in range(1, n - 3):
  if a[i] - a[i - 1] != a[i + 1] - a[i]:
   d = a[i + 3] - a[i + 2]
   a[i + 1] = a[i + 2] - d
   a[i] = a[i + 1] - d
   a[i - 1] = a[i] - d
   f = True
   break

 if (not f):
  if (a[n - 1] - a[n - 4]) / 3 == (a[n - 1] - a[n - 2]):
   d = a[n - 1] - a[n - 2]
   a[n - 3] = a[n - 2] - d
  elif (a[n - 1] - a[n - 4]) / 3 == (a[n - 1] - a[n - 3]) / 2:
   d = a[n - 3] - a[n - 4]
   a[n - 2] = a[n - 3] + d
  elif a[n - 1] - a[n - 2] == a[n - 2] - a[n - 3]:
   d = a[n - 1] - a[n - 2]
   a[n-4] = a[n-3]-d
  else:
   d = a[n - 3] - a[n - 4]
   a[n - 1] = a[n - 2] + d

 [print(x, end=" ") for x in a]
 print()


t = int(input())
for T in range(t):
 n = int(input())
 a = [int(x) for x in input().split()]
 diff = []
 cor = 0
 
 for i in range(1, n):
  diff.append(a[i] - a[i - 1])
 d = set(diff)
 d = list(d)
 
 if len(d) == 1:
  print(*a)
  continue
 if len(d) == 2:
  cor = a[2] - a[1]
  if a[1] - a[0] != cor:
   a[0] = a[1] - cor
  else:
   a[-1] = a[-2] + cor
  print(*a)
  continue

 
 if (d[0] + d[1]) / 2 == d[2]:
  cor = d[2]
 elif (d[1] + d[2]) / 2 == d[0]:
  cor = d[0]
 else:
  cor = d[1]
 for i in range(1, n):
  if a[i] - a[i - 1] != cor:
   a[i] = a[i - 1] + cor
 print(*a)


t=int(input())
for _ in range(t):
 n=int(input())
 a=list(map(int,input().split()))
 if n==4:
  target=-1
  cur=-1
  ind=-1
  s=set()
  flag=False
  for i in range(1,n):
   k=a[i]-a[i-1]
   if k not in s:
    s.add(k)
   else:
    target=k 
    cur=a[i]
    ind=i 
    flag=True
    break
  if flag:
   back=[cur]
   forth=[cur]
   for i in range(ind+1,n):
    forth.append(forth[-1]+target)
   for i in range(ind-1,-1,-1):
    back.append(back[-1]-target)
   back=back[::-1]
   back.pop()
   print(*back,end=" ")
   print(*forth)
  else:
   k=(a[-1]-a[0])//(n-1)
   for i in range(n-1,-1,-1):
    print(a[-1]-k*i,end=" ")
   print() 
 else:
  target=-1
  cur=-1
  ind=-1
  s=set()
  for i in range(1,n):
   k=a[i]-a[i-1]
   if k not in s:
    s.add(k)
   else:
    target=k 
    cur=a[i]
    ind=i 
    break 
  back=[cur]
  forth=[cur]
  for i in range(ind+1,n):
   forth.append(forth[-1]+target)
  for i in range(ind-1,-1,-1):
   back.append(back[-1]-target)
  back=back[::-1]
  back.pop()
  print(*back,end=" ")
  print(*forth)
    

t=int(input())
for _ in range(t):
 n=int(input())
 a=list(map(int,input().split()))
 if n==4:
  target=-1
  cur=-1
  ind=-1
  s=set()
  flag=False
  for i in range(1,n):
   k=a[i]-a[i-1]
   if k not in s:
    s.add(k)
   else:
    target=k 
    cur=a[i]
    ind=i 
    flag=True
    break
  if flag:
   back=[cur]
   forth=[cur]
   for i in range(ind+1,n):
    forth.append(forth[-1]+target)
   for i in range(ind-1,-1,-1):
    back.append(back[-1]-target)
   back=back[::-1]
   back.pop()
   print(*back,end=" ")
   print(*forth)
  else:
   k=(a[-1]-a[0])//(n-1)
   for i in range(n-1,-1,-1):
    print(a[-1]-k*i,end=" ")
   print() 
 else:
  target=-1
  cur=-1
  ind=-1
  s=set()
  for i in range(1,n):
   k=a[i]-a[i-1]
   if k not in s:
    s.add(k)
   else:
    target=k 
    cur=a[i]
    ind=i 
    break 
  back=[cur]
  forth=[cur]
  for i in range(ind+1,n):
   forth.append(forth[-1]+target)
  for i in range(ind-1,-1,-1):
   back.append(back[-1]-target)
  back=back[::-1]
  back.pop()
  print(*back,end=" ")
  print(*forth)
    

for i in range(0,int(input())):
 n=int(input())
 l=list(map(int,input().split()))
 d1=l[1]-l[0]
 d2=l[2]-l[1]
 if(d2==d1):
  ce=l[2]
  for j in range(3,n):
   if l[j]==ce+d1:
    ce+=d1
   else:
    l[j]=ce+d1
    break
 else:
  if l[3]-l[0]==3*d1:
   l[2]=l[1]+d1
  elif l[2]-l[0]==2*(l[3]-l[2]):
   l[1]=l[0]+l[3]-l[2]
  else:
   l[0]=2*l[1]-l[2]
 for j in range(0,n):
  print(l[j],end=" ")
 print("")
 

for _ in range(int(input())):
 N = int(input())
 array = list(map(int, input().split()))
 d1 = array[1] - array[0]
 d2 = array[2] - array[1]
 d3 = array[3] - array[2]
 d = 0
 if d1 == d2:
  d = d1
 elif d1 == d3:
  d = d1
 elif d2 == d3:
  d = d2
 else:
  d = (array[3] - array[0])//3

 for i in range(N-1):
  if array[i+1] - array[i] != d:
   if i == 0:
    if array[2] - array[1] == d:
     array[0] = array[1] - d
    else:
     array[1] = array[0] + d
   else:
    array[i+1] = array[i] + d
   break
 print(*array)

def printAp(a,d,l):
 print(" ".join([str(int(a+(i*d))) for i in range(l)]))
t=int(input())
for i in range(t):
 n=int(input())
 lst=[int(x) for x in input().split(" ")]
 a=0;
 diff=0;
 if ((lst[0]+lst[2])/2==lst[1]):
  a=lst[0]
  diff=lst[1]-lst[0]
 elif ((lst[1]+lst[3])/2==lst[2]):
  diff=lst[2]-lst[1]
  a=lst[1]-diff
 else:
  a=lst[0]
  diff=(lst[3]-lst[0])/3
 printAp(a,diff,n);


def printAp(a,d,l):
 print(" ".join([str(int(a+(i*d))) for i in range(l)]))
t=int(input())
for i in range(t):
 n=int(input())
 lst=[int(x) for x in input().split(" ")]
 a=0;
 diff=0;
 if ((lst[0]+lst[2])/2==lst[1]):
  a=lst[0]
  diff=lst[1]-lst[0]
 elif ((lst[1]+lst[3])/2==lst[2]):
  diff=lst[2]-lst[1]
  a=lst[1]-diff
 else:
  a=lst[0]
  diff=(lst[3]-lst[0])/3
 printAp(a,diff,n);