#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  int n, m;
  cin >> n >> m;
  int arr[n];
  for (int i = 0; i <= n - 1; i++) {
    arr[i] = -1;
  }
  int flag = 0;
  for (int i = 0; i <= m - 1; i++) {
    int a, b;
    cin >> a >> b;
    if ((arr[a - 1] == -1) || (arr[a - 1] == b)) {
      arr[a - 1] = b;
    } else {
      flag = 1;
      break;
    }
  }
  if ((n >= 2) && (arr[0] == 0)) {
    flag = 1;
  }
  if (flag == 0) {
    for (int i = 0; i <= n - 1; i++) {
      if (arr[i] != -1) {
        cout << arr[i];
      } else {
        if (i == 0) {
          cout << "1";
        } else {
          cout << "0";
        }
      }
    }
  } else {
    cout << "-1"
         << "\n";
  }
  return 0;
}
