#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  int count = 0;
  vector<int> ans(n, 99);
  int s, c;
  for (int i = 0; i < m; i++) {
    cin >> s;
    cin >> c;
    if (n != 1 && s == 1 && c == 0)
      count += 1;
    else if (ans[s - 1] == 99)
      ans[s - 1] = c;
    else if (ans[s - 1] == c)
      ans[s - 1] = c;
    else
      count += 1;
  }
  if (count != 0)
    cout << -1;
  else {
    if (ans[0] == 99) ans[0] = 1;
    for (int i = 0; i < n; i++) {
      if (ans[i] == 99) ans[i] = 0;
      cout << ans[i];
    }
  }
}
