/*
URL:
https://codeforces.com/problemset/problem/678/D
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	a, b, x, n int64
)

// ↓でもいい
func main() {
	a, b, n, x = ReadInt64_4()

	A := [][]int64{
		[]int64{a + 1, NegativeMod(-a, MOD)},
		[]int64{1, 0},
	}

	AK := powMat(A, n-1, MOD)

	ans := int64(0)

	big := (a*x + b) % MOD
	big *= AK[0][0]
	ans += big
	ans %= MOD

	sml := AK[0][1]
	sml *= x
	sml %= MOD
	ans += sml
	ans %= MOD

	fmt.Println(ans)
}

// NegativeMod can calculate a right residual whether value is positive or negative.
func NegativeMod(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// n*nのint型正方行列を生成する
func newMat(n int64) [][]int64 {
	var i int64

	A := make([][]int64, n)
	for i = 0; i < n; i++ {
		A[i] = make([]int64, n)
	}

	return A
}

// 行列A, Bに関するA*Bの計算
func mul(A, B [][]int64, mod int64) [][]int64 {
	var i, j, k int64
	var lenA, lenB, lenB0 int64
	lenA = int64(len(A))
	lenB = int64(len(B))
	lenB0 = int64(len(B[0]))

	C := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		C[i] = make([]int64, lenB0)
	}

	for i = 0; i < lenA; i++ {
		for k = 0; k < lenB; k++ {
			for j = 0; j < lenB0; j++ {
				C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod
			}
		}
	}

	return C
}

// 行列Aに関するA^nの計算
func powMat(A [][]int64, n, mod int64) [][]int64 {
	var i int64
	var lenA int64
	lenA = int64(len(A))

	B := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		B[i] = make([]int64, lenA)
	}

	for i = 0; i < lenA; i++ {
		B[i][i] = 1
	}
	for n > 0 {
		if n&1 == 1 {
			B = mul(B, A, mod)
		}
		A = mul(A, A, mod)
		n = (n >> 1)
	}

	return B
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/problemset/problem/678/D
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	a, b, x, n int64
)

func main() {
	a, b, n, x = ReadInt64_4()

	A := [][]int64{
		[]int64{a, b},
		[]int64{0, 1},
	}

	AK := powMat(A, n, MOD)

	ans := AK[0][0] * x
	ans %= MOD
	ans += AK[0][1]
	ans %= MOD
	fmt.Println(ans)
}

// ↓でもいい
// func main() {
// 	a, b, n, x = ReadInt64_4()

// 	A := [][]int64{
// 		[]int64{a + 1, NegativeMod(-a, MOD)},
// 		[]int64{1, 0},
// 	}

// 	AK := powMat(A, n-1, MOD)

// 	ans := int64(0)

// 	big := (a*x + b) % MOD
// 	big *= AK[0][0]
// 	ans += big
// 	ans %= MOD

// 	sml := AK[0][1]
// 	sml *= x
// 	sml %= MOD
// 	ans += sml
// 	ans %= MOD

// 	fmt.Println(ans)
// }

// NegativeMod can calculate a right residual whether value is positive or negative.
func NegativeMod(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// n*nのint型正方行列を生成する
func newMat(n int64) [][]int64 {
	var i int64

	A := make([][]int64, n)
	for i = 0; i < n; i++ {
		A[i] = make([]int64, n)
	}

	return A
}

// 行列A, Bに関するA*Bの計算
func mul(A, B [][]int64, mod int64) [][]int64 {
	var i, j, k int64
	var lenA, lenB, lenB0 int64
	lenA = int64(len(A))
	lenB = int64(len(B))
	lenB0 = int64(len(B[0]))

	C := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		C[i] = make([]int64, lenB0)
	}

	for i = 0; i < lenA; i++ {
		for k = 0; k < lenB; k++ {
			for j = 0; j < lenB0; j++ {
				C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod
			}
		}
	}

	return C
}

// 行列Aに関するA^nの計算
func powMat(A [][]int64, n, mod int64) [][]int64 {
	var i int64
	var lenA int64
	lenA = int64(len(A))

	B := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		B[i] = make([]int64, lenA)
	}

	for i = 0; i < lenA; i++ {
		B[i][i] = 1
	}
	for n > 0 {
		if n&1 == 1 {
			B = mul(B, A, mod)
		}
		A = mul(A, A, mod)
		n = (n >> 1)
	}

	return B
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

import (
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF678D(in io.Reader, out io.Writer) {
	const p int64 = 1e9 + 7
	pow := func(x, n int64) int64 {
		res := int64(1)
		for ; n > 0; n >>= 1 {
			if n&1 == 1 {
				res = res * x % p
			}
			x = x * x % p
		}
		return res
	}

	var a, b, n, x int64
	Fscan(in, &a, &b, &n, &x)
	if an := pow(a, n); a == 1 {
		Fprint(out, (an*x+n%p*b)%p)
	} else {
		Fprint(out, (an*x+(an-1)%p*pow(a-1, p-2)%p*b)%p)
	}
}

func main() { CF678D(os.Stdin, os.Stdout) }

/*
URL:
https://codeforces.com/problemset/problem/678/D
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	a, b, x, n int64
)

func main() {
	a, b, n, x = ReadInt64_4()

	// A := [][]int64{
	// 	[]int64{a + 1, -a},
	// 	[]int64{1, 0},
	// }
	A := [][]int64{
		[]int64{a + 1, NegativeMod(-a, MOD)},
		[]int64{1, 0},
	}

	AK := powMat(A, n-1, MOD)

	ans := int64(0)

	big := (a*x + b) % MOD
	big *= AK[0][0]
	ans += big
	ans %= MOD

	sml := AK[0][1]
	sml *= x
	sml %= MOD
	ans += sml
	ans %= MOD

	fmt.Println(ans)
}

// NegativeMod can calculate a right residual whether value is positive or negative.
func NegativeMod(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// n*nのint型正方行列を生成する
func newMat(n int64) [][]int64 {
	var i int64

	A := make([][]int64, n)
	for i = 0; i < n; i++ {
		A[i] = make([]int64, n)
	}

	return A
}

// 行列A, Bに関するA*Bの計算
func mul(A, B [][]int64, mod int64) [][]int64 {
	var i, j, k int64
	var lenA, lenB, lenB0 int64
	lenA = int64(len(A))
	lenB = int64(len(B))
	lenB0 = int64(len(B[0]))

	C := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		C[i] = make([]int64, lenB0)
	}

	for i = 0; i < lenA; i++ {
		for k = 0; k < lenB; k++ {
			for j = 0; j < lenB0; j++ {
				C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod
			}
		}
	}

	return C
}

// 行列Aに関するA^nの計算
func powMat(A [][]int64, n, mod int64) [][]int64 {
	var i int64
	var lenA int64
	lenA = int64(len(A))

	B := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		B[i] = make([]int64, lenA)
	}

	for i = 0; i < lenA; i++ {
		B[i][i] = 1
	}
	for n > 0 {
		if n&1 == 1 {
			B = mul(B, A, mod)
		}
		A = mul(A, A, mod)
		n = (n >> 1)
	}

	return B
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/problemset/problem/678/D
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	a, b, x, n int64
)

func main() {
	a, b, n, x = ReadInt64_4()

	A := [][]int64{
		[]int64{a + 1, -a},
		[]int64{1, 0},
	}
	// A := [][]int64{
	// 	[]int64{a + 1, NegativeMod(-a, MOD)},
	// 	[]int64{1, 0},
	// }

	AK := powMat(A, n-1, MOD)

	// ans := AK[0][0]*(a*x+b) + AK[0][1]*x
	// ans %= MOD

	ans := int64(0)
	ans += AK[0][0] * (a*x + b)
	ans = NegativeMod(ans, MOD)
	ans += AK[0][1] * x
	ans = NegativeMod(ans, MOD)
	fmt.Println(ans)
}

// NegativeMod can calculate a right residual whether value is positive or negative.
func NegativeMod(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// n*nのint型正方行列を生成する
func newMat(n int64) [][]int64 {
	var i int64

	A := make([][]int64, n)
	for i = 0; i < n; i++ {
		A[i] = make([]int64, n)
	}

	return A
}

// 行列A, Bに関するA*Bの計算
func mul(A, B [][]int64, mod int64) [][]int64 {
	var i, j, k int64
	var lenA, lenB, lenB0 int64
	lenA = int64(len(A))
	lenB = int64(len(B))
	lenB0 = int64(len(B[0]))

	C := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		C[i] = make([]int64, lenB0)
	}

	for i = 0; i < lenA; i++ {
		for k = 0; k < lenB; k++ {
			for j = 0; j < lenB0; j++ {
				C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod
			}
		}
	}

	return C
}

// 行列Aに関するA^nの計算
func powMat(A [][]int64, n, mod int64) [][]int64 {
	var i int64
	var lenA int64
	lenA = int64(len(A))

	B := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		B[i] = make([]int64, lenA)
	}

	for i = 0; i < lenA; i++ {
		B[i][i] = 1
	}
	for n > 0 {
		if n&1 == 1 {
			B = mul(B, A, mod)
		}
		A = mul(A, A, mod)
		n = (n >> 1)
	}

	return B
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/problemset/problem/678/D
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	a, b, x, n int64
)

func main() {
	a, b, n, x = ReadInt64_4()

	A := [][]int64{
		[]int64{a + 1, -a},
		[]int64{1, 0},
	}
	// A := [][]int64{
	// 	[]int64{a + 1, NegativeMod(-a, MOD)},
	// 	[]int64{1, 0},
	// }

	AK := powMat(A, n-1, MOD)

	ans := int64(0)

	big := (a*x + b) % MOD
	big *= AK[0][0]
	ans += big
	ans %= MOD

	sml := AK[0][1]
	sml *= x
	sml %= MOD
	ans += sml
	ans %= MOD

	fmt.Println(ans)
}

// NegativeMod can calculate a right residual whether value is positive or negative.
func NegativeMod(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// n*nのint型正方行列を生成する
func newMat(n int64) [][]int64 {
	var i int64

	A := make([][]int64, n)
	for i = 0; i < n; i++ {
		A[i] = make([]int64, n)
	}

	return A
}

// 行列A, Bに関するA*Bの計算
func mul(A, B [][]int64, mod int64) [][]int64 {
	var i, j, k int64
	var lenA, lenB, lenB0 int64
	lenA = int64(len(A))
	lenB = int64(len(B))
	lenB0 = int64(len(B[0]))

	C := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		C[i] = make([]int64, lenB0)
	}

	for i = 0; i < lenA; i++ {
		for k = 0; k < lenB; k++ {
			for j = 0; j < lenB0; j++ {
				C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod
			}
		}
	}

	return C
}

// 行列Aに関するA^nの計算
func powMat(A [][]int64, n, mod int64) [][]int64 {
	var i int64
	var lenA int64
	lenA = int64(len(A))

	B := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		B[i] = make([]int64, lenA)
	}

	for i = 0; i < lenA; i++ {
		B[i][i] = 1
	}
	for n > 0 {
		if n&1 == 1 {
			B = mul(B, A, mod)
		}
		A = mul(A, A, mod)
		n = (n >> 1)
	}

	return B
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/problemset/problem/678/D
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	a, b, x, n int64
)

func main() {
	a, b, n, x = ReadInt64_4()

	// A := [][]int64{
	// 	[]int64{a + 1, -a},
	// 	[]int64{1, 0},
	// }
	A := [][]int64{
		[]int64{a + 1, NegativeMod(-a, MOD)},
		[]int64{1, 0},
	}

	AK := powMat(A, n-1, MOD)

	// ans := AK[0][0]*(a*x+b) + AK[0][1]*x
	// ans %= MOD

	ans := int64(0)
	ans += AK[0][0] * (a*x + b)
	ans = NegativeMod(ans, MOD)
	ans += AK[0][1] * x
	ans = NegativeMod(ans, MOD)
	fmt.Println(ans)
}

// NegativeMod can calculate a right residual whether value is positive or negative.
func NegativeMod(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// n*nのint型正方行列を生成する
func newMat(n int64) [][]int64 {
	var i int64

	A := make([][]int64, n)
	for i = 0; i < n; i++ {
		A[i] = make([]int64, n)
	}

	return A
}

// 行列A, Bに関するA*Bの計算
func mul(A, B [][]int64, mod int64) [][]int64 {
	var i, j, k int64
	var lenA, lenB, lenB0 int64
	lenA = int64(len(A))
	lenB = int64(len(B))
	lenB0 = int64(len(B[0]))

	C := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		C[i] = make([]int64, lenB0)
	}

	for i = 0; i < lenA; i++ {
		for k = 0; k < lenB; k++ {
			for j = 0; j < lenB0; j++ {
				C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod
			}
		}
	}

	return C
}

// 行列Aに関するA^nの計算
func powMat(A [][]int64, n, mod int64) [][]int64 {
	var i int64
	var lenA int64
	lenA = int64(len(A))

	B := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		B[i] = make([]int64, lenA)
	}

	for i = 0; i < lenA; i++ {
		B[i][i] = 1
	}
	for n > 0 {
		if n&1 == 1 {
			B = mul(B, A, mod)
		}
		A = mul(A, A, mod)
		n = (n >> 1)
	}

	return B
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/problemset/problem/678/D
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	a, b, x, n int64
)

func main() {
	a, b, n, x = ReadInt64_4()

	A := [][]int64{
		[]int64{a + 1, -a},
		[]int64{1, 0},
	}

	AK := powMat(A, n-1, MOD)

	ans := AK[0][0]*(a*x+b) + AK[0][1]*x
	ans %= MOD
	fmt.Println(ans)
}

// NegativeMod can calculate a right residual whether value is positive or negative.
func NegativeMod(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// n*nのint型正方行列を生成する
func newMat(n int64) [][]int64 {
	var i int64

	A := make([][]int64, n)
	for i = 0; i < n; i++ {
		A[i] = make([]int64, n)
	}

	return A
}

// 行列A, Bに関するA*Bの計算
func mul(A, B [][]int64, mod int64) [][]int64 {
	var i, j, k int64
	var lenA, lenB, lenB0 int64
	lenA = int64(len(A))
	lenB = int64(len(B))
	lenB0 = int64(len(B[0]))

	C := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		C[i] = make([]int64, lenB0)
	}

	for i = 0; i < lenA; i++ {
		for k = 0; k < lenB; k++ {
			for j = 0; j < lenB0; j++ {
				C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod
			}
		}
	}

	return C
}

// 行列Aに関するA^nの計算
func powMat(A [][]int64, n, mod int64) [][]int64 {
	var i int64
	var lenA int64
	lenA = int64(len(A))

	B := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		B[i] = make([]int64, lenA)
	}

	for i = 0; i < lenA; i++ {
		B[i][i] = 1
	}
	for n > 0 {
		if n&1 == 1 {
			B = mul(B, A, mod)
		}
		A = mul(A, A, mod)
		n = (n >> 1)
	}

	return B
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/problemset/problem/678/D
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	a, b, x, n int64
)

func main() {
	a, b, n, x = ReadInt64_4()

	A := [][]int64{
		[]int64{a + 1, -a},
		[]int64{1, 0},
	}
	// A := [][]int64{
	// 	[]int64{a + 1, NegativeMod(-a, MOD)},
	// 	[]int64{1, 0},
	// }

	AK := powMat(A, n-1, MOD)

	ans := AK[0][0]*(a*x+b) + AK[0][1]*x
	// ans %= MOD
	ans = NegativeMod(ans, MOD)
	fmt.Println(ans)
}

// NegativeMod can calculate a right residual whether value is positive or negative.
func NegativeMod(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// n*nのint型正方行列を生成する
func newMat(n int64) [][]int64 {
	var i int64

	A := make([][]int64, n)
	for i = 0; i < n; i++ {
		A[i] = make([]int64, n)
	}

	return A
}

// 行列A, Bに関するA*Bの計算
func mul(A, B [][]int64, mod int64) [][]int64 {
	var i, j, k int64
	var lenA, lenB, lenB0 int64
	lenA = int64(len(A))
	lenB = int64(len(B))
	lenB0 = int64(len(B[0]))

	C := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		C[i] = make([]int64, lenB0)
	}

	for i = 0; i < lenA; i++ {
		for k = 0; k < lenB; k++ {
			for j = 0; j < lenB0; j++ {
				C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod
			}
		}
	}

	return C
}

// 行列Aに関するA^nの計算
func powMat(A [][]int64, n, mod int64) [][]int64 {
	var i int64
	var lenA int64
	lenA = int64(len(A))

	B := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		B[i] = make([]int64, lenA)
	}

	for i = 0; i < lenA; i++ {
		B[i][i] = 1
	}
	for n > 0 {
		if n&1 == 1 {
			B = mul(B, A, mod)
		}
		A = mul(A, A, mod)
		n = (n >> 1)
	}

	return B
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/problemset/problem/678/D
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	a, b, x, n int64
)

func main() {
	a, b, n, x = ReadInt64_4()

	// A := [][]int64{
	// 	[]int64{a + 1, -a},
	// 	[]int64{1, 0},
	// }
	A := [][]int64{
		[]int64{a + 1, NegativeMod(-a, MOD)},
		[]int64{1, 0},
	}

	AK := powMat(A, n-1, MOD)

	ans := AK[0][0]*(a*x+b) + AK[0][1]*x
	ans %= MOD
	fmt.Println(ans)
}

// NegativeMod can calculate a right residual whether value is positive or negative.
func NegativeMod(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// n*nのint型正方行列を生成する
func newMat(n int64) [][]int64 {
	var i int64

	A := make([][]int64, n)
	for i = 0; i < n; i++ {
		A[i] = make([]int64, n)
	}

	return A
}

// 行列A, Bに関するA*Bの計算
func mul(A, B [][]int64, mod int64) [][]int64 {
	var i, j, k int64
	var lenA, lenB, lenB0 int64
	lenA = int64(len(A))
	lenB = int64(len(B))
	lenB0 = int64(len(B[0]))

	C := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		C[i] = make([]int64, lenB0)
	}

	for i = 0; i < lenA; i++ {
		for k = 0; k < lenB; k++ {
			for j = 0; j < lenB0; j++ {
				C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod
			}
		}
	}

	return C
}

// 行列Aに関するA^nの計算
func powMat(A [][]int64, n, mod int64) [][]int64 {
	var i int64
	var lenA int64
	lenA = int64(len(A))

	B := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		B[i] = make([]int64, lenA)
	}

	for i = 0; i < lenA; i++ {
		B[i][i] = 1
	}
	for n > 0 {
		if n&1 == 1 {
			B = mul(B, A, mod)
		}
		A = mul(A, A, mod)
		n = (n >> 1)
	}

	return B
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}


package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

var v []int64 = []int64{0,4,10,20,35,56,83,116,155,198,244,292}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int64
	fmt.Fscanf(reader, "%d", &n)

	if int(n) < len(v) {
		fmt.Printf("%d", v[n])
	} else {
		fmt.Printf("%d", 49 * (n - int64(len(v)) + 1) + v[len(v) - 1])
	}
}

package main

import (
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF997B(in io.Reader, out io.Writer) {
	a := [...]int{0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244}
	var n int64
	Fscan(in, &n)
	if n < 11 {
		Fprint(out, a[n])
	} else {
		Fprint(out, 49*n-247)
	}
}

func main() { CF997B(os.Stdin, os.Stdout) }


package main
import "fmt"

func main(){
	var n,count,i int64
	fmt.Scan(&n)
	count=0
	for i=1 ; i<n; i++{
		if (n-i)%i == 0{
			count++
		}
	}
	fmt.Println(count)
}

package main

import "fmt"

func main() {
	cnt := 0
	var n int
	fmt.Scan(&n)
	for i := 1; i <= n/2; i++ {
		if (n-i)%i == 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var count = 0
	_, _ = fmt.Scan(&n)
	for i := 1; i < n; i++ {
		if (n - i) % i == 0 {
			count ++
		}
	}
	fmt.Println(count)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	cnt := 0
	for i := 1; i <= n/2; i++ {
		if (n-i)%i == 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}

package main

import "fmt"

func main(){
	var a int
        var itog int
	fmt.Scan(&a)
	for i := 2; i <= a; i++ {
		if a % i == 0 {
		    itog +=1
		}
	}
	fmt.Println(itog)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := readInt()
	cnt := 0
	for i := 1; i < n; i++ {
		if (n % i) == 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	cnt := 0
	for i:=2; i<=n; i++ {
		if (n%i==0) {
			cnt++
		};
	}
	fmt.Println(cnt);
}

package main

import "fmt"

func main() {
	var n int
	k := 0
	k1 := 1
	fmt.Scan(&n)
	for k1 != n {
		if (n-k1)%k1 == 0 && k1 != n {
			k++
			//fmt.Println((n-k1), (n-k1)%k1)
		}
		k1++
	}
	fmt.Println(k)
}

package main

import (
	"fmt"
)

func main() {

	var n int
	fmt.Scanf("%d\n", &n)

	count := 0
	for i := 1; i <= n/2; i += 1 {
		if (n - i) % i ==0 {
			count+=1
		}
	}
	fmt.Print(count)
}

package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
)

func Employee(number int) int {
	var array []int
	for i:=1;i<=number/2;i++ {
		if number % i == 0 {
			array = append(array,i)
		}
	}
	return len(array)
}

func main() {
	var number int
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text =  strings.TrimRight(text,"\r\n")
	number,_ = strconv.Atoi(text)
	fmt.Println(Employee(number))
}

package main

import (
	"fmt"
	"log"
	"math"
)

func main() {
	var input int
	_, err := fmt.Scanf("%d", &input)

	//validate input
	if err != nil {
		log.Fatal(err)
		return
	}

	if input < 2 || float64(input) > math.Pow10(5) {
		fmt.Println("input out of range")
		return
	}

	count := 1

	for numberOfLeaders := 2; numberOfLeaders <= input/2; numberOfLeaders ++ {
		if input % numberOfLeaders == 0 {
			count += 1
		}
	}

	fmt.Println(count)
}

//A. Фафа и его компания
package main

import (
	"fmt"
)

func main() {
	var n, rez int

	fmt.Scan(&n)

	for i := 2; i <= n; i++ {
		if n%i == 0 {
			rez++
		}
	}

	fmt.Println(rez)
}

// Codeforces helper functions
// 20 Jan 18
// samadhi

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	"unicode"
)

const debug = true

func main() {
	reader := bufio.NewReader(os.Stdin)
	n := gsli(reader)[0]

	ways := 0
	for i := 1; i <= 50000; i++ {
		if (n-i)%i == 0 && n-i > 0 {
			ways++
		}
	}

	fmt.Printf("%v", ways)

}

// Input helpers

// If you don't pass in a reference to the reader, and just instantiate a new
// one every time, it will work locally, with IO typed at human-speed, but not
// on Codeforces.

// Get Space-separated Line as Strings
//
// Example input:
// 1 test 382.0
// Example output:
// ["1", "test", "382.0"]

func gsls(reader *bufio.Reader) (arr []string) {
	// Get a full line
	input, _ := reader.ReadString('\n')

	//Strip newline and return chars, if any
	input = strings.TrimSuffix(input, "\n")
	input = strings.TrimSuffix(input, "\r")

	// Split at the spaces into an array
	arr = strings.Split(input, " ")

	return
}

// Get Space-separated Line as Integers
// Any non-valid integers will be 0
//
// Example input:
// test 1 12.3 -117
// Example output:
// [0, 1, 0, -117]

func gsli(reader *bufio.Reader) (arr []int) {
	stringArr := gsls(reader)

	for _, e := range stringArr {
		cur, _ := strconv.Atoi(e)
		arr = append(arr, cur)
	}

	return
}

// Get Space-separated Line as 64-bit Floats
// Any non-valid floats will be 0
//
// Example input:
// test 128.328 12 -11.0
// Example output:
// [0, 128.328, 12, -11]

func gslf(reader *bufio.Reader) (arr []float64) {
	stringArr := gsls(reader)

	for _, e := range stringArr {
		cur, _ := strconv.ParseFloat(e, 64)
		arr = append(arr, cur)
	}

	return
}

// String helpers

// Is Lowercase
// Given some string[i], return whether it is lower case or not.

func isl(b byte) bool {
	var r rune
	r = rune(b)
	return unicode.IsLower(r)
}

// Math helpers

// Positve Modulo
// Returns x mod y, but always positive

func posMod(x, y int) int {
	return (x%y + y) % y
}

// Max Int
// Returns the max of two ints

func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}

// Output helpers

func yes() {
	fmt.Println("Yes")
}

func no() {
	fmt.Println("No")
}

// Debug helpers

// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss

func dbg(s string, a ...interface{}) {
	if debug {
		fmt.Printf(s, a...)
	}
}

package main

import "fmt"

func main(){
	var n, cnt int
	fmt.Scan(&n)
	for i := 2; i <= n; i++ {
		if n % i == 0 {
			cnt ++
		}
	}
	fmt.Println(cnt)
}

        package main

        import "fmt"

        func main() {
        	var numOfEmployee int
        	fmt.Scan(&numOfEmployee)
        	var count int = 0
        	for i :=1; i <= numOfEmployee/2; i++ {
        		res := numOfEmployee - i
        		if res % i == 0 {
        			count++
        		}
        	}
        	fmt.Println(count)
        }

    package main

    import (
    	"fmt"
    )

    func main() {
    	var numOfEmployee int
    	fmt.Scan(&numOfEmployee)
    	var count int = 0
    	for i :=1; i <= numOfEmployee/2; i++ {
    		res := numOfEmployee - i
    		if res % i == 0 {
    			count++
    		}
    	}
    	fmt.Println(count)
    }

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n uint32
	var c uint32 = 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 1; uint32(i) <= n/2; i++ {
		if (n-uint32(i))%uint32(i) == 0 {
			c++
		}
	}
	fmt.Println(c)
}

package main

import "fmt"

func main(){
	var n int
        var res int
	fmt.Scan(&n)
	for i := 2; i <= n; i++ {
		if n % i == 0 {
		    res +=1
		}
	}
	fmt.Println(res)
}

package main

import "fmt"

func main() {
	var n int
	var count int = 0
	fmt.Scan(&n)
	for i := 1; i < (n/2)+1; i++ {
		if n%i == 0 {
			count += 1
		}
	}
	fmt.Print(count)
}

package main

import "fmt"

func main()  {
	var n int
	fmt.Scanln(&n)
	ans := 0
	for i := 1; i < n; i++ {
		if n % i == 0 {
			ans++
		}
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
)
func main() {
	var t,num int
	fmt.Scan(&t)
	for i:=1;i<t;i++{
		if(t-i)%i==0{
			num++
		}
	}
	fmt.Printf("%d",num)

}

package main

import (
	"fmt"
)

func main()  {
	var num_of_employee int
	fmt.Scan(&num_of_employee)
	count :=0

	for i:=2; i <= num_of_employee; i++{
		if num_of_employee%i ==0{
			count+=1
		}

	}
	fmt.Println(count)
}

package main

import "fmt"

func main(){
	var n int
	var co int = 0
	fmt.Scanln(&n)
	for i := 1; i < n; i++{
		if n%i == 0{
			co++
		}
	}
	fmt.Print(co,"\n")
}

package main

import "fmt"

func main() {
	n := 0
	fmt.Scan(&n)
	max := n / 2
	cnt := 0
	for i:=1; i<=max; i++ {
		if (n-i) % i == 0 {cnt++}
	}
	fmt.Println(cnt)
}

package main

import "fmt"

func main() {
    var n int
    fmt.Scan(&n)
    cnt := 0
    for i:=1; i<n; i++ {
        if n % i == 0 {
            cnt++
        }
    }
    fmt.Print(cnt)
}

package main

import (
	"fmt"
	"log"
)

func main() {
	var num int
	_, err := fmt.Scanf("%d\n", &num)
	if err != nil {
		log.Fatal(err)
	}
	var count int = 0
	for i :=1; i <= num/2; i++ {
		res := num - i
		if res % i == 0 {
			count++
		}
	}
	fmt.Println(count)
}

package main

import (
	"fmt"
)

func main() {
	var num int
	fmt.Scan(&num)
	var count int = 0
	for i :=1; i <= num/2; i++ {
		res := num - i
		if res % i == 0 {
			count++
		}
	}
	fmt.Println(count)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var count = 0
	fmt.Scan(&n)
	for i := 1; i < n; i++ {
		if (n-i)%i == 0 {
			count++
		}
	}
	fmt.Println(count)
}

package main

import "fmt"

var x, res int

func main() {
	fmt.Scanf("%d", &x)
	i := 1
	for i <= x / 2 {
		if x % i == 0 {
			res++
		}
		i++
	}
	fmt.Println(res)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)

	var n uint64
	fmt.Fscanf(in, "%d\n", &n)
	fmt.Println(fafaAndHisCompany(n))
}

func fafaAndHisCompany(n uint64) uint64 {
	var count uint64
	var i uint64 = 1
	for (n-i)/i > 0 {
		if (n-i)%i == 0 {
			count++
		}
		i++
	}

	return count
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var k int

	fmt.Scan(&n)

	for i := 1; i <= n-i; i++ {
		if (n-i)%i == 0 {
			k++
		}
	}

	fmt.Println(k)
}

package main

import (
	"fmt"
)

func main() {
	rs := 1
	n := 0
	fmt.Scan(&n)
	for i := 2; i < n; i++ {
		if n%i == 0 {
			rs++
		}
	}
	fmt.Print(rs)
}

// cf935a project main.go
package main

import (
	"fmt"
)

func main() {
	var n, c int
	fmt.Scan(&n)
	for i := 2; i <= n/2; i++ {
		if n%i == 0 {
			c++
		}
	}
	c++
	fmt.Println(c)
}

package main
import "fmt"
func main() {
    var n, ruk, yes int
    yes = 1
    fmt.Scan(&n)
    for ruk = 2; ruk <= n/2; ruk++{
        if (n - ruk) % ruk == 0{
            yes++
        }
    }
    fmt.Print(yes)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	fact := make([]int, 0)
	count := 0
	for n%2 == 0 {
		count++
		n /= 2
	}
	fact = append(fact, count)
	count = 0
	for i := 3; n > 1; i += 2 {
		for n%i == 0 {
			n /= i
			count++
		}
		if count > 0 {
			fact = append(fact, count)
			count = 0
		}
	}
	ans := 1
	for i := 0; i < len(fact); i++ {
		ans *= (fact[i] + 1)
	}
	fmt.Println(ans - 1)
}

// A. Fafa and his Company
/*
Fafa owns a company that works on huge projects. There are n employees
in Fafa's company. Whenever the company has a new project to start working on,
Fafa has to divide the tasks of this project among all the employees.

Fafa finds doing this every time is very tiring for him. So,
he decided to choose the best l employees in his company as team leaders.
Whenever there is a new project, Fafa will divide the tasks among only
the team leaders and each team leader will be responsible of some positive
number of employees to give them the tasks. To make this process fair
for the team leaders, each one of them should be responsible for the same
number of employees. Moreover, every employee, who is not a team leader,
has to be under the responsibility of exactly one team leader,
and no team leader is responsible for another team leader.

Given the number of employees n, find in how many ways Fafa could choose
the number of team leaders l in such a way that it is possible to divide
employees between them evenly.

Input

The input consists of a single line containing a positive integer
n (2 ≤ n ≤ 105) — the number of employees in Fafa's company.

Output

Print a single integer representing the answer to the problem.

Examples
Input
2

Output
1

Input
10

Output
3

Note
In the second sample Fafa has 3 ways:

    choose only 1 employee as a team leader with 9 employees under his responsibility.
    choose 2 employees as team leaders with 4 employees under the responsibility of each of them.
    choose 5 employees as team leaders with 1 employee under the responsibility of each of them.
*/
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	input, _, _ := reader.ReadLine()
	in, _ := strconv.Atoi(string(input))
	sol935A(in)
}

func sol935A(in int) {
	count := 0
	for i := 1; i < in; i++ {
		if in%i == 0 {
			count++
		}
	}
	fmt.Print(count)
}

// A. Fafa and his Company
/*
Fafa owns a company that works on huge projects. There are n employees
in Fafa's company. Whenever the company has a new project to start working on,
Fafa has to divide the tasks of this project among all the employees.

Fafa finds doing this every time is very tiring for him. So,
he decided to choose the best l employees in his company as team leaders.
Whenever there is a new project, Fafa will divide the tasks among only
the team leaders and each team leader will be responsible of some positive
number of employees to give them the tasks. To make this process fair
for the team leaders, each one of them should be responsible for the same
number of employees. Moreover, every employee, who is not a team leader,
has to be under the responsibility of exactly one team leader,
and no team leader is responsible for another team leader.

Given the number of employees n, find in how many ways Fafa could choose
the number of team leaders l in such a way that it is possible to divide
employees between them evenly.

Input

The input consists of a single line containing a positive integer
n (2 ≤ n ≤ 105) — the number of employees in Fafa's company.

Output

Print a single integer representing the answer to the problem.

Examples
Input
2

Output
1

Input
10

Output
3

Note
In the second sample Fafa has 3 ways:

    choose only 1 employee as a team leader with 9 employees under his responsibility.
    choose 2 employees as team leaders with 4 employees under the responsibility of each of them.
    choose 5 employees as team leaders with 1 employee under the responsibility of each of them.
*/
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	input, _, _ := reader.ReadLine()
	in, _ := strconv.Atoi(string(input))
	sol935A(in)
}

func sol935A(in int) {
	count := 0
	for i := 1; i <= in/2; i++ {
		if in%i == 0 {
			count++
		}
	}
	fmt.Print(count)
}

package main

import "fmt"

func main()  {
	var n int
	fmt.Scan(&n)
	d := 0
	for i:=2 ; i<=n; i++{
		if (n%i==0){
			d++
		}
	}
	fmt.Println(d)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	cnt := 0
	for i:=2; i<=n; i++ {
		if (n%i==0) {
			cnt++
		};
	}
	print(cnt);
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n uint16
	var c uint16 = 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 1; uint16(i) <= n/2; i++ {
		if (n-uint16(i))%uint16(i) == 0 {
			c++
		}
	}
	fmt.Println(c)
}


package main

import "fmt"

func main() {
  var n int64
  fmt.Scan(&n)
  fmt.Println(n / 2520)
}

package main

import (
	"fmt"
)

func main() {
	x := int64(8 * 9 * 5 * 7)
	var n int64
	fmt.Scan(&n)
	fmt.Println(n / x)
}

package main
import "fmt"
func main() {
    var a int64
    fmt.Scanf("%d", &a)
    fmt.Println(a / 2520)
}

//
//
package main

import (
	"fmt"
	"os"
)

const LCM int64 = 2520

func main() {
	var n int64
	if _, err := fmt.Scanf("%d", &n); err != nil {
		fmt.Println("Error: Scanf:", err)
		os.Exit(1)
	}

	fmt.Println(n / LCM)
}

package main
import "fmt"
func main() {
    var a int
    fmt.Scanf("%a", &a)
    fmt.Println(a / 2520)
}

package main
import "fmt"
func main() {
    var a int
    fmt.Scanf("%d", &a)
    fmt.Println(a / 2520)
}

package main
import "fmt"
func main() {
    var a int64
    fmt.Scanf("%lld", &a)
    fmt.Println(a / 2520)
}

package main

import (
	"fmt"
)

func main() {
	x := int64(8 * 9 * 5 * 7)
	var n int64
	fmt.Scan(&n)
	var i = int64(0)

	for ; i*x < n; i = i*i + 1 {
	}

	for ; i*x > n; i /= 2 {
	}

	for ; i*x < n; i++ {
	}
	fmt.Println(i - 1)
}


package main

import "fmt"

func main() {
    var x,y int
    fmt.Scan(&x,&y)
    if x < 0 {
        if y < 0 {
            fmt.Println(x+y,0,0,x+y)
        } else {
            fmt.Println(x-y,0,0,-(x-y))
        }
    } else {
        if y < 0 {
            fmt.Println(0,-(x-y),x-y,0)
        } else {
            fmt.Println(0,x+y,x+y,0)
        }
    }
}

package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	if x < 0 {
		if y < 0 {
			fmt.Println(x+y, 0, 0, x+y)
		} else {
			fmt.Println(x-y, 0, 0, y-x)
		}
	} else {
		if y < 0 {
			fmt.Println(0, y-x, x-y, 0)
		} else {
			fmt.Println(0, x+y, x+y, 0)
		}
	}
}

package main
import (
	"fmt"
	//"unicode/utf8"
)

func main() {
	var a,b int64
	fmt.Scan(&a,&b)
	if a>0 && b>0 {
		fmt.Print("0 ",a+b,a+b," 0")
		fmt.Println()
	} else if a<0 && b>0 {
		fmt.Print(a-b," 0 ","0 ",b-a)
		fmt.Println()
	} else if a<0 && b<0 {
		fmt.Print(a+b," 0 ","0 ",a+b)
		fmt.Println()
	} else if a>0 && b<0 {
	        fmt.Print("0 ",b-a,a-b," 0")
	        fmt.Println()
	}

}

package main

import (
	"fmt"
)

func main() {
	var x, y, gradient, c int64

	fmt.Scan(&x, &y)

	gradient = x*y/abs(x*y)
	c = y + gradient*x

	if x < 0 {
		fmt.Println(-abs(c), 0, 0, c)
	} else {
		fmt.Println(0, c, abs(c), 0)
	}
}

func abs(n int64) int64 {
	if n < 0 {
		return -n
	} else {
		return n
	}
}

package main
import (
	"fmt"
	//"unicode/utf8"
)

func main() {
	var a,b int64 //input
	fmt.Scan(&a,&b)
	if a>0 && b>0 {
		fmt.Print("0 ",a+b,a+b," 0")
		fmt.Println()
	} else if a<0 && b>0 {
		fmt.Print(a-b," 0 ","0 ",b-a)
		fmt.Println()
	} else if a<0 && b<0 {
		fmt.Print(a+b," 0 ","0 ",a+b)
		fmt.Println()
	} else if a>0 && b<0 {
	        fmt.Print("0 ",b-a,a-b," 0")
	        fmt.Println()
	}

}

// 336A
package main

import (
	"fmt"
)

func main() {
	var a,b int
	fmt.Scan(&a, &b)
	x := a+b
	y:= a-b
	if a>0{
		if b>0{
			fmt.Println(0,x,x,0)
		}else{
			fmt.Println(0,-y,y,0)
		}
	} else{
		if b>0{
			fmt.Println(y,0,0,-y)
		}else{
			fmt.Println(x,0,0,x)
		}
	}

}

// 258A-mic
package main

import (
    "fmt"
    "math"
)

func main() {
    var i, k float64
    fmt.Scan(&i, &k)
    t := int64(math.Abs(math.Abs(i) + math.Abs(k)))
    if i > 0 && k > 0 {
        fmt.Printf("0 %d %d 0\n", t, t)
    } else if i > 0 && k < 0 {
        fmt.Printf("0 %d %d 0\n", -t, t)
    } else if i < 0 && k > 0 {
        fmt.Printf("%d 0 0 %d\n", -t, t)
    } else {
        fmt.Printf("%d 0 0 %d\n", -t, -t)
    }
}

package main
import (
	"fmt"
	//"unicode/utf8"
)

func main() {
	var a,b int64
	fmt.Scan(&a,&b)
	if a>0 && b>0 {
		fmt.Print("0 ",a+b,a+b," 0")
		fmt.Println()
	} else if a<0 && b>0 {
		fmt.Print(a-b,"0 ","0 ",b-a)
		fmt.Println()
	} else if a<0 && b<0 {
		fmt.Print(a+b,"0 ","0 ",a+b)
		fmt.Println()
	} else if a>0 && b<0 {
	        fmt.Print("0 ",b-a,a-b," 0")
	        fmt.Println()
	}

}

package main

import (
	"fmt"
)

func main() {
	var x, y, gradient, c int

	fmt.Scan(&x, &y)

	gradient = x*y/abs(x*y)
	c = y + gradient*x

	if x < 0 {
		fmt.Println(-abs(c), 0, 0, c)
	} else {
		fmt.Println(0, c, abs(c), 0)
	}
}

func abs(n int) int {
	if n < 0 {
		return -n
	} else {
		return n
	}
}

// 336A
package main

import (
	"fmt"
)

func main() {
	var a,b int
	fmt.Scan(&a, &b)
	x := a+b
	y:= a-b
	if x>0{
		if y>0{
			fmt.Println(0,x,x,0)
		}else{
			fmt.Println(0,-y,y,0)
		}
	} else{
		if y>0{
			fmt.Println(y,0,0,-y)
		}else{
			fmt.Println(x,0,0,x)
		}
	}

}

// 258A-mic
package main

import (
    "fmt"
    "math"
)

func main() {
    var i, k int
    fmt.Scan(&i, &k)
    t := int64(math.Abs(float64(i + k)))
    if i > 0 && k > 0 {
        fmt.Printf("0 %d %d 0\n", t, t)
    } else if i > 0 && k < 0 {
        fmt.Printf("0 %d %d 0\n", -t, t)
    } else if i < 0 && k > 0 {
        fmt.Printf("%d 0 0 %d\n", -t, t)
    } else {
        fmt.Println("%d 0 0 %d\n", -t, -t)
    }
}

// 258A-mic
package main

import (
    "fmt"
    "math"
)

func main() {
    var i, k float64
    fmt.Scan(&i, &k)
    t := int64(math.Abs(math.Abs(i) + math.Abs(k)))
    if i > 0 && k > 0 {
        fmt.Printf("0 %d %d 0\n", t, t)
    } else if i > 0 && k < 0 {
        fmt.Printf("0 %d %d 0\n", -t, t)
    } else if i < 0 && k > 0 {
        fmt.Printf("%d 0 0 %d\n", -t, t)
    } else {
        fmt.Println("%d 0 0 %d\n", -t, -t)
    }
}