If Give an integer N . Write a program to obtain the sum of the first and last digits of this number.

-----Input-----

The first line contains an integer T, the total number of test cases. Then follow T lines, each line contains an integer N. 

-----Output-----
For each test case, display the sum of first and last digits of N in a new line.

-----Constraints-----
- 1 ≤ T ≤ 1000
- 1 ≤ N ≤ 1000000

-----Example-----
Input
3 
1234
124894
242323

Output
5
5
5

Difficulty: EASY
Tags: Mathematics

Implementation

Complete search
Skill types: Complete search

Starter code:

Solutions:
for i in range(int(input())):
	s = int(input())
	m = []
	while s > 0:
		rem = s % 10
		m.append(rem)
		s = s // 10
	print(m[0] + m[len(m) - 1])


t = int(input())
for i in range(t):

	def first_digit(n):
		while n >= 10:
			n = n / 10
		return int(n)

	def last_digit(n):
		return n % 10
	n = int(input())
	print(first_digit(n) + last_digit(n))


for i in range(int(input())):
	n = input()
	print(int(n[0]) + int(n[len(n) - 1]))


T = int(input())
for i in range(T):
	N = list(input())
	print(int(N[0]) + int(N[-1]))


for i in range(int(input())):
	s = input()
	print(int(s[0]) + int(s[len(s) - 1]))


for _ in range(int(input())):
	n = str(input())
	print(int(n[0]) + int(n[-1]))


for _ in range(int(input())):
	num = input().strip()
	print(int(num[0]) + int(num[-1]))


for _ in range(int(input())):
	s = input()
	sum1 = int(s[0]) + int(s[-1])
	print(sum1)


t = int(input())
for i in range(t):
	x = list(map(int, str(input())))
	print(x[0] + x[-1])


t = int(input())
for i in range(t):
	n = input()
	print(int(n[0]) + int(n[-1]))


a = int(input(''))
A = []
for m in range(a):
	x = int(input(''))
	A.append(x)
for m in range(a):
	b = str(A[m])
	c = int(b[0]) + int(b[len(b) - 1])
	print(c)


n = int(input())
while n > 0:
	a = list(input())
	print(int(a[0]) + int(a[-1]))
	n -= 1


for i in range(int(input())):
	N = int(input())
	N = str(N)
	first_digit = int(N[0])
	last_digit = int(N[-1])
	print(first_digit + last_digit)


n = int(input())
for i in range(n):
	s = input()
	l = len(s)
	n1 = int(s[0])
	n2 = int(s[l - 1])
	print(n1 + n2)


t = int(input())
while t:
	t -= 1
	n = input()
	print(int(n[0]) + int(n[-1]))


T = int(input())
for i in range(T):
	a = input()
	m = a[0]
	n = a[-1]
	print(int(m) + int(n))


t = int(input())
for i in range(t):
	x = input()
	print(int(x[0]) + int(x[len(x) - 1]))


t = int(input())
for i in range(0, t):
	sum = 0
	s = input()
	sum = int(s[0]) + int(s[-1])
	print(sum)


n = int(input())
for i in range(n):
	k = list(input())
	print(int(k[0]) + int(k[len(k) - 1]))


t = int(input())
for i in range(t):
	n = int(input())
	a = n % 10
	while n >= 10:
		n = n / 10
	b = int(n)
	print(a + b)


t = int(input())
for i in range(0, t):
	x = input()
	a = x[0]
	b = x[-1]
	sum = int(a) + int(b)
	print(sum)


t = int(input())
z = []
for i in range(0, t):
	x = input()
	try:
		print(int(x[0]) + int(x[len(x) - 1]))
	except:
		pass


T = int(input())
while T > 0:
	n = input()
	reverse = n[::-1]
	reverse = int(reverse)
	n = int(n)
	first_digit = reverse % 10
	last_digit = n % 10
	sum = first_digit + last_digit
	print(sum)
	T = T - 1


t = int(input())
for i in range(t):
	num = input()
	str1 = int(num[0])
	str2 = int(num[-1])
	print(str1 + str2)


try:
	for _ in range(int(input())):
		s = str(input())
		print(int(s[0]) + int(s[-1]))
except:
	pass


n = int(input())
mylist = []
while n > 0:
	num = input()
	first = num[0]
	last = num[-1]
	first = int(first)
	last = int(last)
	sum = first + last
	mylist.append(sum)
	sum = 0
	n = n - 1
for i in mylist:
	print(i)


for i in range(int(input())):
	s = input()
	a = int(s[0])
	b = int(s[len(s) - 1])
	print(a + b)


t = int(input())
for i in range(t):
	n = input()
	a = int(n[0])
	b = int(n[-1])
	print(a + b)


for i in range(int(input())):
	s = input()
	r = int(s[0])
	p = int(s[len(s) - 1])
	print(r + p)


for i in range(int(input())):
	a = input()
	print(int(a[0]) + int(a[-1]))


t = eval(input())
for i in range(t):
	n = eval(input())
	rem = []
	while n > 0:
		r = n % 10
		rem.append(r)
		n = n // 10
	print(rem[-1] + rem[0])


def sm(b):
	v = 0
	v = b % 10
	c = 0
	while b != 0:
		c = b % 10
		b = b // 10
	return v + c
n = int(input())
a = []
for i in range(0, n):
	no = int(input())
	a.append(no)
for i in range(0, n):
	print(sm(a[i]))


for _ in range(int(input())):
	s = str(input())
	print(int(s[0]) + int(s[-1]))


n = int(input())
while n > 0:
	s = input()
	print(int(s[0]) + int(s[len(s) - 1]))
	n = n - 1


a = int(input())
for i in range(a):
	s = input()
	l = int(s[0])
	k = int(s[len(s) - 1])
	print(l + k)