#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, a = 0, b = 0, c = 0;
    cin >> n;
    vector<int> p(n), px(n), py(n);
    iota(p.begin(), p.end(), 0);
    for (auto& x : px) cin >> x;
    for (auto& y : py) cin >> y;
    do {
        int t0 = 0, t1 = 0;
        for (int i = 0; i < n; i++)
            px[p[i]] > py[i] && t0++, px[p[i]] < py[i] && t1++;
        t0 < t1&& ++b, t0 > t1&& ++a, t0 == t1&& ++c;
    } while (next_permutation(p.begin(), p.end()));
    cout << a << ' ' << b << ' ' << c << '\n';
}