import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable uint mod = 10^^9 + 7;
alias mint = ModInt!mod;

void main() {
    auto s = readln.split.map!(to!int);
    auto n = mint(s[0]);
    auto m = s[1];
    writeln(n^^m);
}

struct ModInt(uint mod) {
    import std.conv : to;

    uint n;

    this(int n) {
        this.n = (n % mod + mod) % mod;
    }

    this(long n) {
        this.n = (n % mod + mod) % mod;
    }

    private this(uint n) {
        this.n = n;
    }

    string toString() {
        return to!string(this.n);
    }

    private uint normilize(uint n) {
        return n < mod ? n : n - mod;
    }

    ModInt pow(uint n, long x) {
        long ret = 1;
        long a = n;
        while (x) {
            if (x & 1) ret = ret * a % mod;
            a = a * a % mod;
            x >>= 1;
        }
        return ModInt(to!ulong(ret));
    }

    ModInt opBinary(string op)(ModInt rhs) {
        static if (op == "+") {
            return ModInt(normilize(n + rhs.n));
        } else if (op == "-") {
            return ModInt(normilize(n + mod - rhs.n));
        } else if (op == "*") {
            return ModInt(to!uint(to!long(n) * rhs.n % mod));
        } else if (op == "/") {
            return this * pow(rhs.n, mod-2);
        } else if (op == "^^") {
            return pow(this.n, rhs.n);
        }
    }

    ModInt opBinary(string op, T)(T rhs) {
        static if (op == "^^") {
            return pow(this.n, rhs);
        }
    }
}

