#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t, c, i, j, k, temp, temp2, n, m, sum = 0;
  string a, b, tem;
  cin >> n >> m;
  string ans = "";
  for (i = 0; i < n; i++) {
    ans += "*";
  }
  for (i = 0; i < m; i++) {
    cin >> temp >> temp2;
    if (ans[temp - 1] != '*' || (n > 1 && temp == 1 && temp2 == 0)) {
      cout << "-1";
      return 0;
    }
    ans[temp - 1] = char(temp2 + 48);
  }
  if (ans[0] == '*') ans[0] = '1';
  for (i = 1; i < n; i++) {
    if (ans[i] == '*') ans[i] = '0';
  }
  cout << ans;
}
