#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 184467440737095516;
long long n, m, visited[10], ans[10], s, c, maxi;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> s >> c;
    ans[s] = max(ans[s], c);
  }
  for (long long i = 1; i <= n; i++) {
    if (ans[1] == 0) {
      cout << -1 << '\n';
      return 0;
    } else {
      cout << ans[i];
    }
  }
  cout << '\n';
}
