#include <bits/stdc++.h>
using namespace std;
int n;
int values[200013];
int m;
int rightmost[200013];
int main() {
  if (fopen("FILENAME.in", "r")) {
    freopen("FILENAME.in", "r", stdin);
    freopen("FILENAME.out", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  if (n > m) swap(n, m);
  long long answer = 1;
  for (int i = 0; i < m; i++) {
    answer *= n;
    answer %= 1000000007LL;
  }
  cout << answer << endl;
}
