#include <bits/stdc++.h>
using namespace std;
const int MX = 200000;
const int inf = 1e9;
const long long mod = 1e9 + 7;
int a[10];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc, cs = 1, n;
  cin >> n >> tc;
  for (int i = 1; i <= n; i++) a[i] = -1;
  while (tc--) {
    int x, y;
    cin >> x >> y;
    if (a[x] != -1 && a[x] != y || n > 1 && x == 1 && y == 0) {
      cout << -1 << endl;
      return 0;
    }
    a[x] = y;
  }
  for (int i = 1; i <= n; i++)
    if (a[i] == -1) a[i] = 0;
  if (a[0] == 0 && n > 1) a[0] = 1;
  for (int i = 1; i <= n; i++) cout << a[i];
  cout << endl;
  return 0;
}
