#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  int arr[n];
  for (int i = 0; i < n; i++) {
    arr[i] = -1;
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    if (t2 == 0 && t1 == 1) {
      ans = -1;
    } else if (arr[t1 - 1] == -1) {
      arr[t1 - 1] = t2;
    } else if (arr[t1 - 1] != t2) {
      ans = -1;
    }
  }
  if (ans == -1)
    cout << -1;
  else {
    for (int i = 0; i < n; i++) {
      if (i == 0 && arr[i] == -1)
        cout << 1;
      else if (arr[i] == -1)
        cout << 0;
      else {
        cout << arr[i];
      }
    }
  }
  return 0;
}
