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, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto L = s[1].to!long;
    auto R = s[2].to!long;

    long r = R + 2 - R % 3;
    long l = L - L % 3;
    long x = (r - l + 1) / 3;

    auto num = new long[](3);
    num[] = x;

    if (L % 3 == 1) {
        num[0] -= 1;
    } else if (L % 3 == 2) {
        num[0] -= 1;
        num[1] -= 1;
    }

    if (R % 3 == 0) {
        num[1] -= 1;
        num[2] -= 1;
    } else if (R % 3 == 1) {
        num[2] -= 1;
    }


    auto dp = new long[][](N+1, 3);
    dp[0][0] = 1;

    foreach (i; 0..N) {
        foreach (j; 0..3) {
            foreach (k; 0..3) {
                (dp[i+1][(j+k)%3] += dp[i][j] * num[k] % MOD) %= MOD;
            }
        }
    }

    dp[N][0].writeln;
}
