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