#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string ans(n, '*');
  for (int i = 0; i < (int)m; i++) {
    int a, b;
    cin >> a >> b;
    if (ans[a - 1] != '*' && ans[a - 1] != b + '0') {
      cout << "-1\n";
      return 0;
    }
    ans[a - 1] = b + '0';
  }
  if (ans[0] == '*') ans[0] = '1';
  if (ans[0] == '0' && n > 1) {
    cout << "-1\n";
    return 0;
  }
  for (int i = 0; i < (int)3; i++)
    if (ans[i] == '*') ans[i] = '0';
  cout << ans << '\n';
  return 0;
}
