Under construction

Still being built. Things may change

Graph Transformation

Time limit1sMemory limit1024 MB

Summary
Given a complete graph with N vertices, find the vertex count after K line-graph transformations, modulo 1000000007.
Level

Medium5 of 10

Topics
Math, Graph
Solved
No attempts yet

Problem

The transformation (f:G↦G′)(f:G \mapsto G') of a graph is defined as follows. Treat each edge of GG as a vertex of G′G'. Connect two vertices of G′G' with an edge when the corresponding edges are adjacent in GG. Two distinct edges are adjacent if they share at least one common vertex.

The transformed graph can be transformed again.

Find the number of vertices of the graph obtained by transforming an NN-complete graph KK times. An NN-complete graph is a graph with NN vertices in which every pair of distinct vertices is joined by an edge.

Input

The first line contains integers NN and KK, separated by a space. (3≤N≤100 0003 \leq N \leq 100\,000, 0≤K≤100 0000 \leq K \leq 100\,000)

Output

Print the remainder when the number of vertices of the graph after KK transformations is divided by 1 000 000 007(=109+7)1\,000\,000\,007 (=10^9 + 7). This number is prime.

Examples1

  1. Example 1

    Input
    4 1
    
    Expected output
    6