#include <bits/stdc++.h>
using namespace std;
bool check(vector<int>& s, vector<int>& c, vector<int>& ans) {
  int N = ans.size();
  int M = s.size();
  for (int i = 0; i < (int)(M); ++i) {
    if (ans[s[i]] == -1 or ans[s[i]] == c[i])
      ans[s[i]] = c[i];
    else
      return false;
  }
  if (N > 1 and ans[0] == 0) return false;
  for (int i = 0; i < (int)(N); ++i)
    if (ans[i] == -1) ans[i] = (i == 0) ? 1 : 0;
  return true;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  for (int i = 0; i < (int)(M); ++i) {
    cin >> s[i] >> c[i];
    --s[i];
  }
  vector<int> ans(N, -1);
  if (check(s, c, ans)) {
    for (int i = 0; i < (int)(N); ++i) cout << ans[i];
    cout << endl;
  } else
    cout << -1 << endl;
  return 0;
}
