#include <bits/stdc++.h>
int64_t inf = 1000000007;
int64_t giant = 4000000000000000037;
using namespace std;
int64_t cup(int64_t xxx, int64_t yyy) { return (xxx + yyy - 1) / yyy; }
int n, m;
void input() { cin >> n >> m; }
int main() {
  input();
  vector<int> ans(n, -1);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (ans[a - 1] != -1 && ans[a - 1] != b) {
      cout << -1 << endl;
      return 0;
    }
    ans[a - 1] = b;
  }
  if (ans[0] == -1) ans[0] = 1;
  for (int i = 1; i < n; i++) {
    if (ans[i] == -1) ans[i] = 0;
  }
  if (ans[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i];
  }
  return 0;
}
