#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) a[i] = 10;
  int s, c;
  int flag = true;
  int j = 0;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (s == 1 && c == 0) flag = false;
    if (a[s - 1] == 10)
      a[s - 1] = c;
    else
      flag = false;
  }
  if (flag) {
    for (int i = 0; i < n; i++) {
      if (a[i] == 0) cout << 1;
      if (a[i] == 10)
        cout << 0;
      else
        cout << a[i];
    }
  } else
    cout << -1;
  return 0;
}
