#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m, s, c;
  cin >> n >> m;
  int a[n];
  for (ll i = 0; i < (n); ++i) a[i] = -1;
  for (ll i = 0; i < (m); ++i) {
    cin >> s >> c;
    if (a[s - 1] != -1 && a[s - 1] != c)
      cout << -1 << endl, exit(0);
    else if (s == 1 && c == 0)
      cout << -1 << endl, exit(0);
    else
      a[s - 1] = c;
  }
  for (ll i = 0; i < (n); ++i) {
    if (a[i] == -1)
      cout << (i == 0);
    else
      cout << a[i];
  }
  cout << endl;
}
