#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int arr[n + 1];
  memset(arr, -1, sizeof(arr));
  int flag = 0;
  for (int i = 0; i < m; i++) {
    int index, val;
    cin >> index >> val;
    if (arr[index] != -1 && arr[index] != val) {
      flag = 1;
    } else {
      arr[index] = val;
    }
  }
  if (flag)
    cout << -1 << endl;
  else {
    string s = "";
    if (arr[1] == 0)
      cout << -1 << endl;
    else if (n == 1) {
      if (arr[1] == -1) {
        cout << 0 << endl;
      }
    } else {
      if (arr[1] == -1) {
        s += '1';
      } else
        s += '0' + arr[1];
      for (int i = 2; i <= n; i++) {
        if (arr[i] == -1) {
          s += '0';
        } else {
          s += '0' + arr[i];
        }
      }
      cout << s << endl;
    }
  }
}
