Given a string S that represents column title of an Excel sheet, find the number that represents that column.
In excel A column is number 1, AA is 27 and so on. 
Example 1:
Input:
S = A
Output: 1
Example 2:
Input:
S = AA
Output: 27
Your Task:
Complete the function ExcelColumnNumber() which takes a string as input and returns an integer.
Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ |S| <=7

Difficulty: EASY
Tags: Number theory
Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
    def ExcelColumnNumber(self, s):
        #code here

Solutions:
class Solution:

	def ExcelColumnNumber(self, s):
		lst = list(s)
		res = 0
		mul = 1
		for i in lst[::-1]:
			res += (ord(i) - 64) * mul
			mul *= 26
		return res


class Solution:

	def ExcelColumnNumber(self, s):
		import string
		dic = dict(zip(list(string.ascii_uppercase), list(range(1, 27))))
		p = len(s)
		i = 0
		res = 0
		while p > 0:
			res += dic[s[i]] * 26 ** (p - 1)
			p = p - 1
			i += 1
		return res


class Solution:

	def ExcelColumnNumber(self, s):
		d = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26}
		n = len(s)
		res = 0
		for i in range(n):
			res += d[s[i].lower()] * 26 ** (n - i - 1)
		return res


class Solution:

	def ExcelColumnNumber(self, s):
		m = 0
		j = 0
		list1 = [chr(i + 64) for i in range(1, 27)]
		for i in range(len(s) - 1, -1, -1):
			m += (list1.index(s[i]) + 1) * 26 ** j
			j += 1
		return m


class Solution:

	def ExcelColumnNumber(self, s):
		k = 0
		a = s[::-1]
		for i in range(len(a)):
			k = k + (ord(a[i]) - 64) * 26 ** i
		return k


class Solution:

	def ExcelColumnNumber(self, s):
		result = 0
		for B in range(len(s)):
			result *= 26
			result += ord(s[B]) - ord('A') + 1
		return result


class Solution:

	def ExcelColumnNumber(self, s):
		n = len(s)
		ans = 0
		for i in range(n):
			ans += pow(26, n - i - 1) * (ord(s[i]) - 64)
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		excel_dict = {}
		for i in range(1, 27):
			excel_dict[chr(i + 64)] = i
		val = 0
		for char in s:
			val = val * 26 + excel_dict[char]
		return val


class Solution:

	def ExcelColumnNumber(self, n):
		lst = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
		s = 0
		(i, j) = (len(n) - 1, 1)
		while i > -1:
			k = lst.index(n[i]) + 1
			s += k * j
			j *= 26
			i -= 1
		return s


class Solution:

	def ExcelColumnNumber(self, s):

		def solve(i):
			(x, res, temp) = (26, 1, i)
			while temp > 0:
				if temp % 2 == 0:
					x *= x
					temp /= 2
				else:
					res *= x
					temp -= 1
			return res
		dict1 = {}
		t = 1
		for i in range(65, 65 + 26):
			dict1[chr(i)] = t
			t += 1
		ans = 0
		for i in reversed(range(len(s))):
			ans += solve(len(s) - i - 1) * dict1[s[i]]
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		m = 0
		c = 1
		for i in s[::-1]:
			m += c * (ord(i) - 64)
			c = c * 26
		return m


class Solution:

	def ExcelColumnNumber(self, s):
		memo = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'I': 9, 'J': 10, 'K': 11, 'L': 12, 'M': 13, 'N': 14, 'O': 15, 'P': 16, 'Q': 17, 'R': 18, 'S': 19, 'T': 20, 'U': 21, 'V': 22, 'W': 23, 'X': 24, 'Y': 25, 'Z': 26}
		count = 0
		sum = 0
		n = len(s)
		for i in range(n - 1, -1, -1):
			currentValue = s[i]
			sum = sum + pow(26, count) * memo[currentValue]
			count = count + 1
		return sum


class Solution:

	def ExcelColumnNumber(self, s):
		su = 0
		l = len(s) - 1
		for i in range(len(s)):
			c = ord(s[i])
			c = c - 64
			su += c * 26 ** l
			l -= 1
		return su


class Solution:

	def ExcelColumnNumber(self, s):
		s = s[::-1]
		j = 0
		num = 0
		for i in s:
			num += pow(26, j) * (ord(i) - 64)
			j += 1
		return num


class Solution:

	def ExcelColumnNumber(self, s):
		res = 0
		for i in s:
			t = ord(i) - ord('A') + 1
			res = res * 26 + t
		return res


class Solution:

	def ExcelColumnNumber(self, s):
		alphabets = {}
		i = 1
		j = 65
		while j <= 90:
			alphabets[chr(j)] = i
			i += 1
			j += 1
		if len(s) == 1:
			return alphabets[s]
		ans = 0
		n = len(s)
		for i in range(n):
			ans = ans * 26 + alphabets[s[i]]
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		self.s = s
		res = 0
		for i in range(len(s)):
			res = res * 26
			res = res + ord(s[i]) - ord('A') + 1
		return res


class Solution:

	def ExcelColumnNumber(self, string):
		n = len(string)
		result = 0
		for i in range(n):
			result *= 26
			result += ord(string[i]) - 65 + 1
		return result


class Solution:

	def ExcelColumnNumber(self, s):
		ans = 0
		for i in s:
			ans = ans * 26 + (ord(i) - 65 + 1)
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		res = 0
		for char in s:
			res *= 26
			res += ord(char) - ord('A') + 1
		return res


class Solution:

	def ExcelColumnNumber(self, s):
		ans = 0
		for ch in s:
			ans = ans * 26 + (ord(ch) - ord('A') + 1)
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		ans = 0
		s = s[::-1]
		for i in range(len(s)):
			val = ord(s[i]) - 64
			ans += val * 26 ** i
		return ans
if __name__ == '__main__':
	t = int(input())
	for tcs in range(t):
		s = input()
		ob = Solution()
		print(ob.ExcelColumnNumber(s))


class Solution:

	def ExcelColumnNumber(self, s):
		ans = 0
		curr = 1
		for i in range(len(s) - 1, -1, -1):
			value = ord(s[i]) - ord('A') + 1
			ans += curr * value
			curr *= 26
		return ans
if __name__ == '__main__':
	t = int(input())
	for tcs in range(t):
		s = input()
		ob = Solution()
		print(ob.ExcelColumnNumber(s))


class Solution:

	def ExcelColumnNumber(self, s):
		value = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
		n = len(s)
		ans = 0
		for i in range(n):
			ans = 26 * ans + (ord(s[i]) - 64)
		return ans
if __name__ == '__main__':
	t = int(input())
	for tcs in range(t):
		s = input()
		ob = Solution()
		print(ob.ExcelColumnNumber(s))


class Solution:

	def ExcelColumnNumber(self, s):
		ans = 0
		for i in range(0, len(s)):
			x = len(s) - 1 - i
			ans += (ord(s[i]) - ord('A') + 1) * pow(26, x)
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		n = len(s)
		i = 0
		ans = 0
		while i < n:
			x = ord(s[i]) - ord('A') + 1
			y = x * pow(26, n - i - 1)
			ans += y
			i += 1
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		ans = s[::-1]
		a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
		sum = 0
		for i in range(0, len(ans)):
			sum = sum + (a.index(ans[i]) + 1) * 26 ** i
		return sum


class Solution:

	def ExcelColumnNumber(self, s):
		ans = 0
		n = len(s) - 1
		for i in s:
			ans += (ord(i) - ord('A') + 1) * 26 ** n
			n -= 1
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		res = 0
		for c in s:
			d = ord(c) - ord('A') + 1
			res = res * 26 + d
		return res


class Solution:

	def ExcelColumnNumber(self, s):
		x = 0
		for i in range(0, len(s)):
			x = x + 26 ** i
		k = 'A' * len(s)
		if k == s:
			return x
		else:
			t = 0
			r = 0
			for i in range(len(s) - 1, -1, -1):
				t1 = ord(s[i]) - ord('A')
				r = r + 26 ** t * t1
				t += 1
			r = r + x
			return r


class Solution:

	def ExcelColumnNumber(self, s):
		ans = 0
		for i in range(len(s)):
			ans = ans * 26 + int(ord(s[i])) - 64
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		total_sum = 0
		index = 0
		for i in range(len(s) - 1, -1, -1):
			total_sum += (ord(s[i]) - ord('A') + 1) * pow(26, index)
			index += 1
		return total_sum


class Solution:

	def ExcelColumnNumber(self, s):
		a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
		X = 1
		z = 0
		for i in range(len(s) - 1, -1, -1):
			z = z + (a.index(s[i]) + 1) * X
			X = X * 26
		return z


class Solution:

	def ExcelColumnNumber(self, s):
		alpa = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
		res = 0
		t = 1
		for i in range(len(s) - 1, -1, -1):
			res += (alpa.index(s[i]) + 1) * t
			t = t * 26
		return res


class Solution:

	def ExcelColumnNumber(self, s):
		s = s[::-1]
		sum = 0
		k = 0
		for j in s:
			sum += (ord(j) - 64) * 26 ** k
			k += 1
		return sum


class Solution:

	def ExcelColumnNumber(self, s):
		s = s[::-1]
		ans = 0
		summed = 0
		for i in range(len(s)):
			temp = 26 ** i
			val = ord(s[i]) - 65 + 1
			another = temp * val
			ans += another
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		k = 0
		j = len(s) - 1
		for i in range(len(s)):
			a = 26 ** j * (ord(s[i]) - 65 + 1)
			k = k + int(a)
			j -= 1
		return k


from collections import defaultdict
import string

class Solution:

	def ExcelColumnNumber(self, s):
		col_num = 0
		for i in range(len(s)):
			col_num *= 26
			col_num += ord(s[i]) - ord('A') + 1
		return col_num


class Solution:

	def ExcelColumnNumber(self, s):
		result = 0
		for a in s:
			b = ord(a) - ord('@')
			result = result * 26 + b
		return result


class Solution:

	def ExcelColumnNumber(self, s):
		result = 0
		power = 0
		for char in s:
			result = result * 26 + (ord(char) - 65) + 1
		return result


class Solution:

	def ExcelColumnNumber(self, s):
		d = dict()
		for (i, c) in enumerate('ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
			d[c] = i + 1
		s = s[::-1]
		res = 0
		for (i, c) in enumerate(s):
			res += d[c] * 26 ** i
		return res


class Solution:

	def ExcelColumnNumber(self, s):
		k = 0
		ans = 0
		for i in s[::-1]:
			ans += (ord(i) - ord('A') + 1) * pow(26, k)
			k += 1
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		c = 0
		for i in s:
			c = c * 26 + ord(i) - ord('A') + 1
		return c


class Solution:

	def ExcelColumnNumber(self, s):
		li = list(s)
		sum = 0
		prod = 1
		for i in range(len(li) - 1, -1, -1):
			sum += prod * (ord(li[i]) - 64)
			prod *= 26
		return sum


class Solution:

	def ExcelColumnNumber(self, s):
		ans = 0
		count = 0
		for ch in s[::-1].upper():
			ans += 26 ** count * (ord(ch) - 64)
			count += 1
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		r = 0
		for i in range(len(s)):
			r = r * 26
			r = r + (ord(s[i]) - 65 + 1)
		return r


class Solution:

	def ExcelColumnNumber(self, s):
		multiplier = 1
		number = 0
		for char in s[::-1]:
			number += (ord(char) - 64) * multiplier
			multiplier *= 26
		return number


class Solution:

	def ExcelColumnNumber(self, s):
		dict = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'I': 9, 'J': 10, 'K': 11, 'L': 12, 'M': 13, 'N': 14, 'O': 15, 'P': 16, 'Q': 17, 'R': 18, 'S': 19, 'T': 20, 'U': 21, 'V': 22, 'W': 23, 'X': 24, 'Y': 25, 'Z': 26}
		ans = 0
		b = 26
		for i in s:
			if i in dict.keys():
				ans = ans * b + dict[i]
		return ans


class Solution:

	def ExcelColumnNumber(self, s):
		strlen = len(s)
		res = 0
		for char in s:
			res += (ord(char) - ord('A') + 1) * pow(26, strlen - 1)
			strlen -= 1
		return res