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