#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, m, i, x, y;
  string str;
  cin >> n >> m;
  for (i = 0; i < n; i++) str += '0';
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    str[x - 1] = char(y + 48);
  }
  if (str[0] == '0') {
    if (n == 1)
      cout << str << endl;
    else
      cout << "-1" << endl;
  } else
    cout << str << endl;
  return 0;
}
