#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;
int n;
int m;
int x;
int y;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  string s = string(n, '0');
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    s[x - 1] = (y + '0');
  }
  while (!s.empty() && *s.begin() == '0') {
    s.erase(s.begin());
  }
  if ((int)s.size() == n) {
    cout << s << "\n";
  } else {
    cout << "-1\n";
  }
}
