#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
constexpr int MAX_N=500000;
constexpr ll MOD=1e9+7;
vector<int> G[MAX_N];

ll qpow(ll a,ll n)
{
    ll res=1;
    while(n>0) {
        if(n&1) {
            res=res*a%MOD;
        }
        a=a*a%MOD;
        n>>=1;
    }
    return res;
}

int main()
{
    freopen("barrack.in","r",stdin);
    freopen("barrack.out","w",stdout);
    int n,m;
    cin >> n >> m;
    bool flaga=true;
    int u,v;
    if(m!=n-1) {
        flaga=false;
    }
    for(int i=1; i<=m; i++) {
        cin >> u >> v;
        if(u!=i||v!=i+1) {
            flaga=false;
        }
    }
    ll ans=0;
    for(int i=n; i>=1; i--) {
        if(i<=n-2) {
            ans=(ans+((i*qpow(2,i-1))%MOD)*qpow(2,n-i-1))%MOD;
        }else{
            ans=(ans+i*qpow(2,i-1))%MOD;
        }
    }
    cout << ans << endl;
    return 0;
}