# Arup Guha
# 7/23/2014
# Solution to 2013 SI@UCF Contest Problem: The Simplex Method

def main():

    myFile = open("simplex.in")
    numCases = int(myFile.readline().strip())

    # Go through each case.
    for loop in range(1, numCases+1):

        # Get input.
        terms = myFile.readline().split()

        # Go through terms.
        found = False
        ans = 0
        for item in terms:

            # Screen for x term.
            if item[len(item)-1] =='x':
                ans = int(item[:len(item)-1])
                found = True
                
        # Output accordingly.
        if found:
            print(ans)
        else:
            print("x not found")

main()
