#include <bits/stdc++.h>
using namespace std;
int n, m, s, c;
vector<int> ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    ans.push_back(-1);
  }
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    s--;
    if (ans[s] != -1 && ans[s] != c) {
      cout << -1;
      return 0;
    } else
      ans[s] = c;
  }
  if (ans[0] == 0 && n > 1) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] == -1) {
      if (i == 0)
        ans[i] = 1;
      else
        ans[i] = 0;
    }
  }
  for (auto i : ans) cout << i;
}
