using System; public class Hello { static void Main() { var T = int.Parse(Console.ReadLine().Trim()); while (T-- > 0) { var s = Console.ReadLine().Trim(); getAns(s); } } static void getAns(string s) { if (s.Length == 1) { Console.WriteLine(s); return; } long ans; if (s[1] == 'x') ans = Convert.ToInt64(s, 16); else if (s[1] == 'o') ans = Convert.ToInt64(s.Substring(2), 8); else if (s[1] == 'b') ans = Convert.ToInt64(s.Substring(2), 2); else ans = long.Parse(s); Console.WriteLine(ans); } }