Given a number N, find the sum of first and last digit of N. 
 
Example 1:
Input: N = 12345
Output: 6
Explanation: 1st and last digits are 1 and 5.
Example 2:
Input: 98562
Output: 11
Explanation: 1st and last digits are 9 and 2. 
 
Your Task:
You don't need to read or print anything. Your task is to complete the function corner_digitSum() which takes N as input parameter and returns the sum of first and last digit of N.
 
Expect Time Compelxity: O(log_{10}(N))
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{9}

Source: geeksforgeeks | Difficulty: EASY
Tags: Number theory

Starter code: #User function Template for python3

class Solution:
	def corner_digitSum(self, n):
		# Code here

Solutions:
class Solution:

	def corner_digitSum(self, n):
		if n < 10:
			return n
		f = str(n)[0]
		l = str(n)[-1]
		return int(f) + int(l)


class Solution:

	def corner_digitSum(self, n):
		str_n = str(n)
		list_n = list(map(int, str_n))
		if len(list_n) == 1:
			return list_n[0]
		else:
			return list_n[0] + list_n[-1]


class Solution:

	def corner_digitSum(self, n):
		m = str(n)
		if len(m) == 1:
			return int(m)
		return int(m[0]) + int(m[-1])


class Solution:

	def corner_digitSum(self, n):
		st = str(n)
		if len(st) == 1:
			return st
		sum = int(st[0]) + int(st[-1])
		return sum


class Solution:

	def corner_digitSum(self, n):
		k = str(n)
		l = k[0]
		j = k[-1]
		g = len(k)
		if g == 1:
			return n
		else:
			return int(l) + int(j)


class Solution:

	def corner_digitSum(self, n):
		if n < 10:
			return n
		else:
			s = str(n)
			n = int(s[0])
			n1 = int(s[-1])
			return n + n1


class Solution:

	def corner_digitSum(self, n):
		s = str(n)
		if n > 9:
			k = n % 10
			j = int(n / 10 ** (len(s) - 1))
			return int(k + j)
		else:
			return n


class Solution:

	def corner_digitSum(self, n):
		if n < 10:
			return n
		left = int(str(n)[0])
		right = int(str(n)[len(str(n)) - 1])
		return left + right


class Solution:

	def corner_digitSum(self, n):
		if n < 10:
			return n
		lst = n % 10
		while n >= 10:
			n //= 10
		return lst + n


class Solution:

	def corner_digitSum(self, n):
		n = str(n)
		n.split()
		if len(n) == 1:
			return n[0]
		else:
			s = int(n[len(n) - 1]) + int(n[0])
			return s


class Solution:

	def corner_digitSum(self, n):
		if n // 10 == 0:
			return n
		else:
			i = 10
			u = n % 10
			r = 1
			temp = 0
			while r != 0:
				temp = r
				r = n // i
				i *= 10
			sum_ = temp + u
		return sum_
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		n = int(input())
		ob = Solution()
		ans = ob.corner_digitSum(n)
		print(ans)


class Solution:

	def corner_digitSum(self, n):
		n = str(n)
		if len(n) == 1:
			return n
		return int(n[0]) + int(n[-1])
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		n = int(input())
		ob = Solution()
		ans = ob.corner_digitSum(n)
		print(ans)


class Solution:

	def getCount(n):
		c = 0
		while n != 0:
			n //= 10
			c += 1
		return c

	def corner_digitSum(self, n):
		if n < 10:
			return n
		c = Solution.getCount(n)
		f = n // 10 ** (c - 1)
		l = n % 10
		return f + l


class Solution:

	def corner_digitSum(self, n):
		if n > 9:
			u = []
			while n != 0:
				x = n % 10
				u.append(x)
				n = n // 10
			return u[0] + u[-1]
		else:
			return n


class Solution:

	def corner_digitSum(self, n):
		if n < 10:
			return n
		else:
			l = n % 10
			while n > 9:
				n //= 10
				f = n
		return f + l


class Solution:

	def corner_digitSum(self, n):
		sum = list(str(n))
		a = int(sum[0])
		b = int(sum[-1])
		if len(sum) == 1:
			return n
		else:
			return a + b


class Solution:

	def corner_digitSum(self, n):
		if n < 10:
			return n
		else:
			last_digit = n % 10
			while n >= 10:
				n = n / 10
			return int(n) + last_digit


class Solution:

	def corner_digitSum(self, n):
		if n <= 9:
			return n
		n = str(n)
		return int(n[0]) + int(n[-1])


class Solution:

	def corner_digitSum(self, n):
		n = str(n)
		y = n[0]
		z = n[-1]
		if int(n) > 9:
			return int(y) + int(z)
		else:
			return int(n)


class Solution:

	def corner_digitSum(self, n):
		M = n
		rf = 0
		while M > 0:
			rl = n % 10
			M = M // 10
			if 0 < M < 10:
				rf = M
		result = rf + rl
		return result


class Solution:

	def corner_digitSum(self, n):
		self.n = n
		conv_str = str(n)
		if len(conv_str) == 1:
			return n
		else:
			(first, last) = (conv_str[0], conv_str[-1])
			summing = int(first) + int(last)
			return summing


import math

class Solution:

	def corner_digitSum(self, n):
		if n < 10:
			return n
		lent = int(math.log10(n))
		first = int(n / pow(10, lent))
		last = n % 10
		return first + last


class Solution:

	def corner_digitSum(self, n):
		N = n
		if len(str(N)) == 1:
			return N
		else:
			l = list(str(N))
			first_no = int(l[0])
			last_no = int(l[-1])
			return first_no + last_no