#include <bits/stdc++.h>
using namespace std;
void _150() {
  long long n;
  cin >> n;
  int temp;
  vector<int> p, q;
  vector<int> perm_base;
  for (int i = 0; i < n; ++i) {
    cin >> temp;
    p.push_back(temp);
    perm_base.push_back(i + 1);
  }
  for (int i = 0; i < n; ++i) {
    cin >> temp;
    q.push_back(temp);
  }
  long long a, b, index;
  a = -1;
  b = -1;
  index = 0;
  do {
    if (perm_base == p) {
      a = index;
    }
    if (perm_base == q) {
      b = index;
    }
    if (a != -1 && b != -1) {
      break;
    }
    index++;
  } while (next_permutation(perm_base.begin(), perm_base.end()));
  cout << abs(a - b) << endl;
}
void _151() {
  int n, m;
  cin >> n >> m;
  int p[100000] = {0};
  int correct[100000] = {0};
  int penalty_counts[100000] = {0};
  string temp;
  int correct_count = 0;
  for (int i = 0; i < m; ++i) {
    cin >> p[i] >> temp;
    if (temp == "AC") {
      if (correct[p[i] - 1] != 1) {
        correct_count++;
        correct[p[i] - 1] = 1;
      }
    } else {
      if (correct[p[i] - 1] != 1) {
        penalty_counts[p[i] - 1]++;
      }
    }
  }
  int penalty_count = 0;
  for (int i = 0; i < n; ++i) {
    if (correct[i] == 1) {
      penalty_count += penalty_counts[i];
    }
  }
  cout << correct_count << " " << penalty_count << endl;
}
void _152_() {
  int n;
  cin >> n;
  int temp;
  vector<int> p;
  int min_val = numeric_limits<int>::max();
  int count = 0;
  for (int i = 0; i < n; ++i) {
    cin >> temp;
    if (min_val >= temp) {
      min_val = temp;
      count++;
    }
  }
  cout << count << endl;
}
void _153() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  if (n <= k) {
    cout << 0 << endl;
    return;
  }
  sort(h.begin(), h.end());
  int num_monsters = n - k;
  long long count = 0;
  for (int i = 0; i < num_monsters; ++i) {
    count += h[i];
  }
  cout << count << endl;
}
void _154() {
  int n;
  cin >> n;
  int temp;
  set<int> b;
  for (int i = 0; i < n; ++i) {
    cin >> temp;
    b.insert(temp);
  }
  if (b.size() != n) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
}
void _155() {
  int n;
  cin >> n;
  string temp;
  map<string, int> data;
  vector<string>::iterator itr;
  vector<int> counts;
  int prev_count, temp_count;
  for (int i = 0; i < n; ++i) {
    cin >> temp;
    temp_count = data[temp];
    data[temp] = ++temp_count;
  }
  int max_count = 0;
  vector<string> candidate;
  for (auto itr = data.begin(); itr != data.end(); ++itr) {
    if (itr->second > max_count) {
      max_count = itr->second;
      candidate.clear();
      candidate.push_back(itr->first);
    } else if (itr->second == max_count) {
      candidate.push_back(itr->first);
    }
  }
  sort(candidate.begin(), candidate.end());
  for (int i = 0; i < candidate.size(); ++i) {
    cout << candidate[i] << endl;
  }
}
void _156() {
  int n;
  cin >> n;
  vector<int> x(n);
  int temp;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> temp;
    sum += temp;
    x[i] = temp;
  }
  int p = std::round((float)sum / n);
  long long result = 0;
  for (int i = 0; i < n; ++i) {
    result += pow(x[i] - p, 2);
  }
  cout << result << endl;
}
void _157() {
  int n, m;
  cin >> n >> m;
  char result[4] = "aaa";
  result[n] = 0;
  int index;
  char temp;
  bool error = false;
  for (int i = 0; i < m; ++i) {
    cin >> index >> temp;
    if ((index == 1) && (temp == '0') && (n != 1)) {
      error = true;
      continue;
    }
    if ((result[index - 1] != 'a') && (result[index - 1] != temp)) {
      error = true;
      continue;
    }
    result[index - 1] = temp;
  }
  if (error) {
    cout << -1 << endl;
    return;
  }
  for (int i = 0; i < n; ++i) {
    if (result[i] == 'a') {
      if (i == 0) {
        result[i] = '1';
      } else {
        result[i] = '0';
      }
    }
  }
  cout << result << endl;
}
int main() {
  _157();
  return 0;
}
