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