#include <bits/stdc++.h>
using namespace std;
long long ar[101];
void solve() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < (n + 1); ++i) ar[i] = -1;
  for (long long i = 0; i < (m); ++i) {
    long long x, y;
    cin >> x >> y;
    if (ar[x] != -1 && y != ar[x]) {
      cout << "-1\n";
      return;
    }
    ar[x] = y;
  }
  if (n == 1 && ar[1] == -1) {
    cout << "0";
    return;
  }
  if (ar[1] == 0)
    cout << -1;
  else {
    if (ar[1] == -1)
      cout << 1;
    else
      cout << ar[1];
    for (long long i = 2; i <= n; i++)
      if (ar[i] == -1)
        cout << 0;
      else
        cout << ar[i];
  }
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
