#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  vector<int> arr(n + 1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    arr[s] = c;
  }
  int ans = 0;
  if (arr[1] == 0 && n > 1) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    ans *= 10;
    ans += arr[i];
  }
  cout << ans << endl;
}
