#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <cmath>

using namespace std;

const int N = 1e6 + 10; 
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;

struct node {
    int x, y;
    bool operator < (const node &a) const {
        if (x != a.x) return x < a.x;
        else return y < a.y; 
    }
};

node s[N], t[N];


int c[111];
bool cmp1(const node &a, const node &b) {
    if (a.x != b.x) return a.x > b.x;
    else return a.y > b.y;
}

int main() {
    int n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        int ma = 0;
        for (int i = 1; i <= n; ++i) scanf("%d%d", &s[i].x, &s[i].y), ma = max(ma, s[i].y);
        for (int i = 1; i <= m; ++i) scanf("%d%d", &t[i].x, &t[i].y);
        sort(s + 1, s + n + 1, cmp1);
        sort(t + 1, t + m + 1, cmp1);
        int num = 0;long long ans = 0;
        memset(c, 0, sizeof(c));
        int id = 1;
        for (int i = 1; i <= m; ++i) {
            while (id <= n && s[id].x >= t[i].x) {
                ++c[s[id].y];
                ++id;
            }
            for (int j = t[i].y; j <= ma; ++j) {
                if (c[j] != 0) {
                    --c[j];
                    ++num;
                    ans += t[i].x * 500 + t[i].y * 2;
                    break;
                }
            }
        }
        printf("%d %I64d\n", num, ans);
    }
    return 0;
}