def process_query(file):
    """ (file open for reading) -> query dictionary
    
    Return the query of file in the query dictionary format. 
    
    """
    
    # Initialize the query_dict.
    query_dict = {}
    line = file.readline().strip()
    
    # Generate the key: 'search' and its value in the query_dict.
    query_dict['search'] = {}
    query_dict['search']['username'] = file.readline().strip()
    query_dict['search']['operations'] = []
    operations = file.readline().strip()
    while operations != 'FILTER':
        query_dict['search']['operations'].append(operations)
        operations = file.readline().strip()
    
    # Generate the key: 'filter' and its value in the query_dict.
    query_dict['filter'] = {}
    line = file.readline().strip()
    while line != 'PRESENT':
        a = line.split()
        query_dict['filter'][a[0]] = a[1]
        line = file.readline().strip()
    
    # Generate the key: 'present' and its value in the query_dict.
    query_dict['present'] = {}
    line = file.readline().strip()
    while line != '':
        b = line.split()
        query_dict['present'][b[0]] = b[1]
        line = file.readline().strip()
    
    return query_dict