#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
using namespace std;
template <class T>
bool umin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool umax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
const int MOD = 998244353;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T power(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
long long nCr(long long n, long long r) {
  long long t = 1;
  if (r > n) return 0;
  if (r > n - r) r = n - r;
  for (long long i = 0; i < r; i++) {
    t *= (n - i);
    t /= (i + 1);
  }
  return t;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
void read(vector<int>& a) {
  for (long long i = 0; i < a.size(); ++i) cin >> a[i];
}
void read(vector<long double>& a) {
  for (long long i = 0; i < a.size(); ++i) cin >> a[i];
}
bool prime(long long t) {
  for (long long i = 2; i * i <= t; ++i) {
    if (t % i == 0) return 0;
  }
  return 1;
}
bool cmp(pair<int, int>& a, pair<int, int>& b) {
  if (a.second == b.second) return a.first > b.first;
  return a.second < b.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int a[m + 1][2];
  bool ok = 1;
  for (long long i = 0; i < m; ++i) {
    cin >> a[i][0] >> a[i][1];
    if (a[i][0] == 0 || a[i][0] > n) {
      ok = 0;
    }
  }
  if (!ok) {
    cout << -1;
    return 0;
  }
  map<int, int> dig;
  for (long long i = 1; i < m + 1; ++i) {
    dig[i] = -1;
  }
  for (long long i = 0; i < m; ++i) {
    if (dig[a[i][0]] == -1) {
      dig[a[i][0]] = a[i][1];
    } else {
      if (a[i][1] != dig[a[i][0]]) {
        cout << -1;
        return 0;
      }
    }
  }
  for (long long i = 1; i < n + 1; ++i) {
    if (dig[i] == -1 && i == 1) {
      dig[i] = 1;
    } else if (dig[i] == -1) {
      dig[i] = 0;
    }
  }
  if (dig[1] == 0) {
    cout << -1;
    return 0;
  }
  for (long long i = 1; i < n + 1; ++i) {
    cout << dig[i];
  }
  return 0;
}
