#include <bits/stdc++.h>
const long long int MOD = 1e9 + 7;
const int MAXN = 100005;
const int INF = 1e8;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  pair<int, char> arr[n];
  for (int i = 0; i < m; i++) cin >> arr[i].first >> arr[i].second;
  string s;
  if (n == 1) {
    cout << arr[0].second;
    return 0;
  }
  int j = pow(10, n - 1);
  int h = pow(10, n);
  for (int i = j; i <= h; i++) {
    s = to_string(i);
    bool ok = 1;
    for (int l = 0; l < m; l++)
      if (s[arr[l].first - 1] != arr[l].second) ok = 0;
    if (ok) {
      cout << s;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
