#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, m, ok = 1;
  cin >> n >> m;
  vector<long long> a(n, 0), vis(n, 0);
  while (m--) {
    long long i, d;
    cin >> i >> d;
    i--;
    if (vis[i] && a[i] != d) ok = 0;
    vis[i] = 1;
    a[i] = d;
  }
  if (vis[0] && a[0] == 0 && n > 1)
    ok = 0;
  else if (!vis[0])
    a[0] = 1;
  else if (!ok)
    cout << "-1";
  else
    for (long long i = 0; i < n; i++) cout << a[i];
}
