#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  memset(a, 0, sizeof(a));
  while (m--) {
    int s, c;
    cin >> s >> c;
    a[s - 1] = c;
  }
  int count = 0;
  int ans = -1;
  int flag = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      if (flag) cout << "-1" << endl;
    } else {
      flag = 0;
    }
  }
  string myans = "";
  if (flag == 1) {
    for (int i = 0; i < n; i++) {
      myans += to_string(a[i]);
    }
    cout << myans << endl;
  }
  return 0;
}
