159_B. Matchmaker
Polycarpus has n markers and m marker caps. Each marker is described by two numbers: xi is the color and yi is the diameter. Correspondingly, each cap is described by two numbers: aj is the color and bj is the diameter. Cap (aj, bj) can close marker (xi, yi) only if their diameters match, that is, bj = yi. Besides, a marker is considered to be beautifully closed, if the cap color and the marker color match, that is, aj = xi.

Find the way to close the maximum number of markers. If there are several such ways, then choose the one that has the maximum number of beautifully closed markers.

Input

The first input line contains two space-separated integers n and m (1 ≤ n, m ≤ 105) — the number of markers and the number of caps, correspondingly. 

Next n lines describe the markers. The i-th line contains two space-separated integers xi, yi (1 ≤ xi, yi ≤ 1000) — the i-th marker's color and diameter, correspondingly.

Next m lines describe the caps. The j-th line contains two space-separated integers aj, bj (1 ≤ aj, bj ≤ 1000) — the color and diameter of the j-th cap, correspondingly.

Output

Print two space-separated integers u, v, where u is the number of closed markers and v is the number of beautifully closed markers in the sought optimal way. Remember that you have to find the way to close the maximum number of markers, and if there are several such ways, you should choose the one where the number of beautifully closed markers is maximum.

Examples

Input

3 4
1 2
3 4
2 4
5 4
2 4
1 1
1 2


Output

3 2


Input

2 2
1 2
2 1
3 4
5 1


Output

1 0

Note

In the first test sample the first marker should be closed by the fourth cap, the second marker should be closed by the first cap and the third marker should be closed by the second cap. Thus, three markers will be closed, and two of them will be beautifully closed — the first and the third markers.
```python
def main():
    from sys import stdin
    l = list(map(int, stdin.read().split()))
    n, yx = l[0] * 2, [[0] * 1001 for _ in range(1001)]
    cnt = yx[0]
    u = v = 0
    for y, x in zip(l[3:n + 3:2], l[2:n + 2:2]):
        cnt[y] += 1
        yx[y][x] += 1
    ba, l = list(zip(l[n + 3::2], l[n + 2::2])), []
    for y, x in ba:
        if yx[y][x]:
            yx[y][x] -= 1
            cnt[y] -= 1
            v += 1
        else:
            l.append(y)
    for y in l:
        if cnt[y]:
            cnt[y] -= 1
            u += 1
    print(u + v, v)


if __name__ == '__main__':
    main()

```