public class Euler759 {
    static final long MOD = 1000000007L;
    static final int MAX_BITS = 64;

    static class Aggregates {
        long[] cnt = new long[MAX_BITS + 1];
        long[] sx = new long[MAX_BITS + 1];
        long[] sx2 = new long[MAX_BITS + 1];
        long[] sc = new long[MAX_BITS + 1];
        long[] sc2 = new long[MAX_BITS + 1];
        long[] sxc = new long[MAX_BITS + 1];
        long[] sxc2 = new long[MAX_BITS + 1];
        long[] sx2c = new long[MAX_BITS + 1];
        long[] sx2c2 = new long[MAX_BITS + 1];
    }

    static long addMod(long a, long b) {
        long r = a + b;
        return (r >= MOD) ? (r - MOD) : r;
    }

    static long mulMod(long a, long b) {
        return (a * b) % MOD;
    }

    static Aggregates buildAggregates() {
        Aggregates ag = new Aggregates();
        ag.cnt[0] = 1;

        for (int m = 0; m < MAX_BITS; ++m) {
            long n = ag.cnt[m];
            long sx = ag.sx[m];
            long sx2 = ag.sx2[m];
            long sc = ag.sc[m];
            long sc2 = ag.sc2[m];
            long sxc = ag.sxc[m];
            long sxc2 = ag.sxc2[m];
            long sx2c = ag.sx2c[m];
            long sx2c2 = ag.sx2c2[m];

            long twoSx = mulMod(2, sx);
            long fourSx = mulMod(4, sx);
            long fourSx2 = mulMod(4, sx2);
            long twoSc = mulMod(2, sc);

            long eCnt = n;
            long eSx = twoSx;
            long eSx2 = fourSx2;
            long eSc = sc;
            long eSc2 = sc2;
            long eSxc = mulMod(2, sxc);
            long eSxc2 = mulMod(2, sxc2);
            long eSx2c = mulMod(4, sx2c);
            long eSx2c2 = mulMod(4, sx2c2);

            long oCnt = n;
            long oSx = addMod(twoSx, n);
            long oSx2 = addMod(addMod(fourSx2, fourSx), n);
            long oSc = addMod(sc, n);
            long oSc2 = addMod(addMod(sc2, twoSc), n);

            long oSxc = 0;
            oSxc = addMod(oSxc, mulMod(2, sxc));
            oSxc = addMod(oSxc, sc);
            oSxc = addMod(oSxc, twoSx);
            oSxc = addMod(oSxc, n);

            long oSxc2 = 0;
            oSxc2 = addMod(oSxc2, mulMod(2, sxc2));
            oSxc2 = addMod(oSxc2, sc2);
            oSxc2 = addMod(oSxc2, mulMod(4, sxc));
            oSxc2 = addMod(oSxc2, mulMod(2, sc));
            oSxc2 = addMod(oSxc2, twoSx);
            oSxc2 = addMod(oSxc2, n);

            long oSx2c = 0;
            oSx2c = addMod(oSx2c, mulMod(4, sx2c));
            oSx2c = addMod(oSx2c, mulMod(4, sxc));
            oSx2c = addMod(oSx2c, sc);
            oSx2c = addMod(oSx2c, fourSx2);
            oSx2c = addMod(oSx2c, fourSx);
            oSx2c = addMod(oSx2c, n);

            long oSx2c2 = 0;
            oSx2c2 = addMod(oSx2c2, mulMod(4, sx2c2));
            oSx2c2 = addMod(oSx2c2, mulMod(4, sxc2));
            oSx2c2 = addMod(oSx2c2, sc2);
            oSx2c2 = addMod(oSx2c2, mulMod(8, sx2c));
            oSx2c2 = addMod(oSx2c2, mulMod(8, sxc));
            oSx2c2 = addMod(oSx2c2, mulMod(2, sc));
            oSx2c2 = addMod(oSx2c2, fourSx2);
            oSx2c2 = addMod(oSx2c2, fourSx);
            oSx2c2 = addMod(oSx2c2, n);

            ag.cnt[m + 1] = addMod(eCnt, oCnt);
            ag.sx[m + 1] = addMod(eSx, oSx);
            ag.sx2[m + 1] = addMod(eSx2, oSx2);
            ag.sc[m + 1] = addMod(eSc, oSc);
            ag.sc2[m + 1] = addMod(eSc2, oSc2);
            ag.sxc[m + 1] = addMod(eSxc, oSxc);
            ag.sxc2[m + 1] = addMod(eSxc2, oSxc2);
            ag.sx2c[m + 1] = addMod(eSx2c, oSx2c);
            ag.sx2c2[m + 1] = addMod(eSx2c2, oSx2c2);
        }

        return ag;
    }

    static long blockSum(long prefixValueMod, long prefixPopcount, int lowerBits, Aggregates ag) {
        long p = prefixValueMod;
        long c = prefixPopcount % MOD;
        long p2 = mulMod(p, p);
        long c2 = mulMod(c, c);

        long ans = 0;
        ans = addMod(ans, mulMod(mulMod(ag.cnt[lowerBits], p2), c2));
        ans = addMod(ans, mulMod(ag.sc[lowerBits], mulMod(mulMod(2, p2), c)));
        ans = addMod(ans, mulMod(ag.sc2[lowerBits], p2));
        ans = addMod(ans, mulMod(ag.sx[lowerBits], mulMod(mulMod(2, p), c2)));
        ans = addMod(ans, mulMod(ag.sxc[lowerBits], mulMod(mulMod(4, p), c)));
        ans = addMod(ans, mulMod(ag.sxc2[lowerBits], mulMod(2, p)));
        ans = addMod(ans, mulMod(ag.sx2[lowerBits], c2));
        ans = addMod(ans, mulMod(ag.sx2c[lowerBits], mulMod(2, c)));
        ans = addMod(ans, ag.sx2c2[lowerBits]);
        return ans;
    }

    static long S(long n, Aggregates ag, long[] pow2Mod) {
        long ans = 0;
        long prefixValueMod = 0;
        long prefixPopcount = 0;

        for (int bit = MAX_BITS - 1; bit >= 0; --bit) {
            if (((n >> bit) & 1L) == 0L) {
                continue;
            }
            ans = addMod(ans, blockSum(prefixValueMod, prefixPopcount, bit, ag));
            prefixValueMod = addMod(prefixValueMod, pow2Mod[bit]);
            ++prefixPopcount;
        }

        long p2 = mulMod(prefixValueMod, prefixValueMod);
        long c = prefixPopcount % MOD;
        long c2 = mulMod(c, c);
        ans = addMod(ans, mulMod(p2, c2));
        return ans;
    }

    public static String solve() {
        Aggregates ag = buildAggregates();
        long[] pow2Mod = new long[MAX_BITS + 1];
        pow2Mod[0] = 1;
        for (int i = 1; i <= MAX_BITS; ++i) {
            pow2Mod[i] = mulMod(2, pow2Mod[i - 1]);
        }

        return Long.toString(S(10000000000000000L, ag, pow2Mod));
    }

    public static void main(String[] args) {
        System.out.println(solve());
    }
}
