#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<char> memo(n, '0');
  vector<int> mark(n, -1);
  memo[0] = '1';
  for (int i = 1; i <= m; i++) {
    int s;
    char c;
    cin >> s >> c;
    if (mark[s - 1] == -1)
      mark[s - 1] = (int)c;
    else if (mark[s - 1] != (int)c)
      return cout << -1, 0;
    memo[s - 1] = c;
  }
  if (memo[0] == '0') return cout << -1, 0;
  for (char c : memo) cout << c;
  return 0;
}
