// Arup Guha
// 4/9/2017
// Solution to 1992 UCF HS Contest Problem: There and Back Again

import java.util.*;

public class back {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		// Process all cases.
		while (stdin.hasNext()) {

			// Get input.
			int n = stdin.nextInt();
			int a = stdin.nextInt();
			int b = stdin.nextInt();
			int c = stdin.nextInt();

			// Set 0 term.
			int res = c;

			// Compute terms in order.
			for (int i=1; i<=n; i++) 
				res = a*res + b;

			// Output result.
			System.out.println("f("+n+") = "+res);
		}
	}
}