#include <bits/stdc++.h>
using namespace std;
int mpow(int base, int exp);
void ipgraph(long long n, long long m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
vector<long long> g[N];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  long long t, i, j, k, p, q, l, r, x, y, u, v, n, m;
  cin >> n >> m;
  string s = "";
  for (i = 0; i < n; i++) s += '0';
  pair<long long, long long> a[m];
  for (i = 0; i < m; i++) {
    cin >> a[i].first >> a[i].second;
    s[a[i].first - 1] = '0' + a[i].second;
  }
  long long flag = 1;
  for (i = 0; i < m; i++) {
    if (s[a[i].first - 1] != '0' + a[i].second) {
      cout << "-1";
      return 0;
    }
  }
  long long cnt = 0;
  for (i = 0; i < n; i++) {
    if (s[i] == '0' and flag == 1)
      cnt++;
    else {
      flag = 0;
    }
  }
  if (cnt == 0)
    cout << s;
  else {
    cout << "-1";
  }
  return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long)result * base) % mod;
    base = ((long long)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
void ipgraph(long long n, long long m) {
  int i, u, v;
  while (m--) {
    cin >> u >> v;
    g[u - 1].push_back(v - 1);
    g[v - 1].push_back(u - 1);
  }
}
void dfs(int u, int par) {
  for (int v : g[u]) {
    if (v == par) continue;
    dfs(v, u);
  }
}
