跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F2599. Liars and Serge

    ID: 2605 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>动态规划挑战难度共享题库Codeforces英文题面题目来源题面语言

Liars and Serge

题目描述

D. Liars and Serge
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

There 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 a1,a2,...,an, where ai 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≤kn≤28). 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

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 2251 题。保留原作者与原赛事署名。