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