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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}


const int INF=1001001001;

const int V=400;

int N,M;
int S[444],T[444];

int calcMax(){
    vector<vint>lis(V);
    rep(i,N+M)lis[S[i]].pb(i);

    priority_queue<int,vint,greater<int>>que;
    int ans=0;
    for(int i=0;i<V;i++){
        for(auto k:lis[i])que.push(T[k]);
        while(que.size()&&que.top()<=i)que.pop();
        if(que.size()){
            ans++;
            que.pop();
        }
    }
    return ans;
}

bool ok[444];


vint calc(vpint &lis,vector<vint>&G,bool right){

    vector<vint>bucket(V);
    rep(i,lis.size())bucket[lis[i].fi].pb(i);

    priority_queue<pint,vector<pint>,greater<pint>>que;

    vint nex(V,-1),rev(lis.size(),-1),dom(V,-1);
    vpint mem(V);
    rep(i,V){
        for(auto k:bucket[i])que.emplace(lis[k].se,k);
        while(que.size()&&que.top().fi<=i)que.pop();

        if(ok[i]){
            auto p=que.top();
            que.pop();
            rev[p.se]=i;
            mem[i]=p;
        }

        if(que.size()){
            nex[i]=que.top().se;
        }
    }

    rep(i,V){
        if(!ok[i])continue;
        for(int j=i+1;j<V;j++){
            if(!ok[j])continue;
            if(mem[i].fi<=j)break;
            if(mem[i]<mem[j]){
                dom[i]=j;
                break;
            }
        }
    }

    
    vint ret;
    rep(i,V){
        if(ok[i])continue;
        int v=i;
        while(nex[v]!=-1&&rev[nex[v]]!=-1)v=rev[nex[v]];
        if(nex[v]!=-1)ret.pb(i);
    }

    rep(i,V){
        if(!ok[i])continue;
        vint check(V);
        int v=i;
        while(v!=-1){
            check[v]=true;
            int r;
            if(dom[v]==-1)r=V;
            else r=dom[v];
            for(int j=v+1;j<r;j++){
                if(ok[j])continue;
                if(mem[v].fi>j)check[j]=true;
            }
            v=dom[v];
        }
        vint dp(V);
        for(int j=V-1;j>=0;j--){
            dp[j]=check[j];
            if(nex[j]!=-1&&rev[nex[j]]!=-1)dp[j]|=dp[rev[nex[j]]];
            if(!ok[j]&&dp[j]){
                if(right){
                    G[j].pb(i);
                }
                else{
                    G[i].pb(j);
                }
            }
        }
    }
    return ret;
}

int calcMin(){
    vpint A,B;
    rep(i,M)A.eb(S[i],T[i]);
    rep(i,N)B.eb(S[i+M],T[i+M]);

    while(true){
        vector<vint>G(V);
        vint src=calc(A,G,false);
        vint snk=calc(B,G,true);
        

        vint dist(V,INF),pre(V,-1);
        queue<int>que;
        for(auto v:src){
            dist[v]=0;
            que.push(v);
        }
        while(que.size()){
            int v=que.front();
            que.pop();
            for(auto u:G[v]){
                if(dist[u]!=INF)continue;
                dist[u]=dist[v]+1;
                pre[u]=v;
                que.push(u);
            }
        }
        int nx=-1;
        for(auto v:snk){
            if(dist[v]==INF)continue;
            if(nx==-1||dist[nx]>dist[v])nx=v;
        }
        if(nx==-1)break;
        while(nx!=-1){
            ok[nx]^=1;
            nx=pre[nx];
        }
    }

    int ans=0;
    rep(i,V)if(ok[i])ans++;
    return ans;
}

signed main(){


    cin>>N>>M;
    N-=M;
    rep(i,N+M){
        cin>>S[i]>>T[i];
        S[i]--;
    }

    cout<<calcMax()<<endl;
    cout<<calcMin()<<endl;
    return 0;
}



Measured memory_bytes: 3540