Problem: Every one is now a days playing games on their smartphones for passing free time. Because of which there are number of game developing companies growing in the market. Not only that, each company is now flooding the market with a lot of games. With such a huge number of games in the market, for each company, with millions of users, keeping track of all the data and maintaining good user experience is now a big problem for them.

One of the very important aspect of building these games is the ability to maintain all the information about the user. 
This is a very important step in maintaining the user experience. No user would want to restart from the beginning of the game every time he/she restarts it. They would just then switch to a competitive game developer and that is not good for business.
Most of the games now have a similar structure and some of the game companies follows the logic below in their games to handle this problem:
The game has N different parameters on which a user's strength in the game is calculated. The game has a total of M different levels of play.
    And hence each parameter also gets these M levels of granularity, i.e. for each parameter itself a user can be on any one of those M levels.
For each parameter, the following is done:
    
User's strength on the parameter is calculated.
Each of the M levels have some strength value associated with them such that the strength value grows when you move from a lower level to the higher level. It may happen that any two consecutive levels have same required strength.
If a user's strength is more than or equal to the strength value associated with a level, he/she is said to be fit to be on that level of the game
        for this parameter.
The level for this parameter is the maximum level for which a user satisfies the above criteria.
The level of the game a user is on, is decided from its level in all of the N parameters of the game as follows:
    
For each parameter, the level user is on for that parameter is computed as described above.
The level of game at which a user is the minimum of all the levels in each of the N parameters.

You are now interested in building a game for the smartphone user's as well. But before that, you would need to solve this problem effeciently.
Given the strength of user's for each parameter, print the level they are on.

Input:
The first line of the input contains three space separated integers, N, M and Q. (N is the number of parameters, M is the number of levels, and Q is the 
number of queries that you have to answer.) 
Next N line contains M space separated integers, the i^th line contains the M strength values for the M levels of the i^th
level.

Next Q lines, each contains N space separated integers, the strength of a user in each of the N parameters.

Output:
Print Q lines, one for each query. For each query, print the level on which that user is.

Constraints:
1 ≤ N ≤ 100 
1 ≤ M ≤ 5000 
1 ≤ Q ≤ 5000  
Every input will fit in an integer.

SAMPLE INPUT
2 3 3
10 20 30
7 14 100
11 7
35 13
100 1002

SAMPLE OUTPUT
1
1
3

Solution (in PYTHON):

Solution:
#def bisect_left(a, x, lo=0, hi=None):
def bisect_left(level_strengths, one_player):
    """Return the index where to insert item x in list a, assuming a is sorted.

    The return value i is such that all e in a[:i] have e < x, and all e in
    a[i:] have e >= x.  So if x already appears in the list, a.insert(x) will
    insert just before the leftmost x already there.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.
    """



    for param in range(N):
        x = one_player[param]
        lo = 0
        hi = len(level_strengths[param])
        while lo < hi:
            mid = (lo+hi)//2
            if level_strengths[param][mid] <= x: lo = mid+1
            else: hi = mid
        yield lo

[N, M, Q] = [int(i) for i in raw_input().split()] # Do not use ' ' !!!
level_strengths = [[0] * M ] * N
players_strengths = [[0] * N ] * Q
for param in range(N):
    level_strengths[param] = [int(i) for i in raw_input().split()] 
for query in range(Q):
    players_strengths[query] = [int(i) for i in raw_input().split()] 
#print "N = %d, M = %d, Q = %d" %(N, M, Q)
#print "level_strengths = {}".format(level_strengths)
#print "players_strengths = {}".format(players_strengths)

for query in range(Q):
    decide_levels = bisect_left(level_strengths, players_strengths[query])
    print min(decide_levels)