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