#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> s1(m), c(m);
  for (int i = 0; i < m; i++) cin >> s1[i] >> c[i];
  if (m < n)
    cout << -1 << endl;
  else {
    string s;
    if (n == 0) n = 1;
    for (int i = 0; i < n; i++) s += '0';
    for (int i = 0; i < m; i++) s[s1[i] - 1] = (char)c[i] + '0';
    cout << s << endl;
  }
}
