Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
D. Liars and Serge

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputThere are *n* people, sitting in a line at the table. For each person we know that he always tells either the truth or lies.

Little Serge asked them: how many of you always tell the truth? Each of the people at the table knows everything (who is an honest person and who is a liar) about all the people at the table. The honest people are going to say the correct answer, the liars are going to say any integer from 1 to *n*, which is not the correct answer. Every liar chooses his answer, regardless of the other liars, so two distinct liars may give distinct answer.

Serge does not know any information about the people besides their answers to his question. He took a piece of paper and wrote *n* integers *a*_{1}, *a*_{2}, ..., *a*_{n}, where *a*_{i} is the answer of the *i*-th person in the row. Given this sequence, Serge determined that exactly *k* people sitting at the table apparently lie.

Serge wonders, how many variants of people's answers (sequences of answers *a* of length *n*) there are where one can say that exactly *k* people sitting at the table apparently lie. As there can be rather many described variants of answers, count the remainder of dividing the number of the variants by 777777777.

Input

The first line contains two integers *n*, *k*, (1 ≤ *k* ≤ *n* ≤ 2^{8}). It is guaranteed that *n* — is the power of number 2.

Output

Print a single integer — the answer to the problem modulo 777777777.

Examples

Input

1 1

Output

0

Input

2 1

Output

2

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/29/2020 07:46:22 (f3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|