#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, ans = -1, buf;
  string s;
  cin >> n >> m;
  if (n > 1)
    s.push_back('1');
  else
    s.push_back('0');
  for (long long i = 1; i < n; i++) s.push_back('0');
  vector<pair<long long, long long>> a(m);
  for (long long i = 0; i < m; i++) cin >> a[i].first >> a[i].second;
  a.push_back({4, 0});
  sort(a.begin(), a.end());
  for (long long i = 0; i < m; i++) {
    buf = a[i].second;
    if (a[i].first != a[i + 1].first)
      s[a[i].first - 1] = (char)buf + '0';
    else if (a[i].second != a[i + 1].second) {
      s[0] = '0';
      break;
    }
  }
  if (s[0] == '0')
    cout << ans << endl;
  else
    cout << s << endl;
}
