#include <bits/stdc++.h>
using namespace std;

vector<pair<vector<int>, int>> run_length(vector<vector<int>>& v) {
    sort(v.begin(), v.end());
    vector<pair<vector<int>, int>> rl;
    
    vector<int> prev;
    for (auto x : v) {
        if (x != prev)
            rl.push_back({x, 1});
        else
            rl.back().second += 1;

        prev = x;
    }

    return rl;
}

int main() {
    int T, S, Q;
    scanf("%d%d%d", &T, &S, &Q);

    vector<vector<int>> tests(T, vector<int>(Q)), students(S, vector<int>(Q));

    for (int i=0; i<T; i++) {
        for (int j=0; j<Q; j++)
            scanf("%d", &tests[i][j]);

        sort(tests[i].begin(), tests[i].end());
    }

    for (int i=0; i<S; i++) {
        for (int j=0; j<Q; j++)
            scanf("%d", &students[i][j]);

        sort(students[i].begin(), students[i].end());
    }

    auto tests_rl = run_length(tests);
    auto students_rl = run_length(students);

    long long answer = 0;

    auto it = tests_rl.begin();
    auto jt = students_rl.begin();
    while (it != tests_rl.end()) {
        while (jt != students_rl.end() and jt->first < it->first)
            ++jt;

        if (jt != students_rl.end() and it->first == jt->first)
            answer += it->second * 1LL * jt->second;

        ++it;
    }

    cout << answer << endl;
}
