import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
import java.math.BigInteger;
import java.net.PortUnreachableException;
import java.util.*;

// written by luchy0120

public class Main {
    public static void main(String[] args) throws Exception {

        new Main().run();
    }

    static int groups = 0;
    static int[] fa;
    static int[] sz;

    static void init(int n) {
        groups = n;
        fa = new int[n];
        for (int i = 1; i < n; ++i) {
            fa[i] = i;
        }
        sz = new int[n];
        Arrays.fill(sz, 1);
    }

    static int root(int p) {
        while (p != fa[p]) {
            fa[p] = fa[fa[p]];
            p = fa[p];
        }
        return p;
    }

    static void combine(int p, int q) {
        int i = root(p);
        int j = root(q);
        if (i == j) {
            return;
        }
        if (sz[i] < sz[j]) {
            fa[i] = j;
            sz[j] += sz[i];
        } else {
            fa[j] = i;
            sz[i] += sz[j];
        }
        groups--;
    }

    int child[];
    int color[],dfn[],low[],stack[],cnt[];
    boolean vis[];
    boolean iscut[];
    int deep,top,n,m,sum,ans;
    List<Integer> g[];
    int root = 0;
    //  无向图的强连通分量
    void tarjanNonDirect(int u1) {

        int stk[] = new int[10001];
        int fatk[] = new int[10001];
        int p = 0;
        stk[p] = u1;
        fatk[p] = -1;
        p= 1;
        ot: while(p>0) {
            int u  = stk[p-1];
            int fa = fatk[p-1];

            if(dfn[u]==0) {
                low[u] = dfn[u] = ++deep;
            }
            // stack[top++] = u;

            for (; h[u] != -1; h[u] = ne[h[u]]) {
                int v = to[h[u]];
                if (dfn[v] == 0) {
                    //tarjanNonDirect(v);

                    fatk[p] = u;
                    stk[p++] = v;
                    continue ot;
                } else {
                    low[u] = Math.min(low[u], dfn[v]);
                    // 没有特判是否直接指向父亲
                    // 回边，使用dfn【v】更新low【u】,因为可能是指向父亲，而父亲的low可能比较小
                }
            }
            --p;

            if (fa != -1) {
                low[fa] = Math.min(low[fa], low[u]);
                if (low[u] >= dfn[fa]) {
                    if (fa != root || ++child[fa] > 1) {     // 不是root，直接记为cut，是root，判断是否有两个儿子
                        iscut[fa] = true;
                    }
                    ++dcc_cnt;
                    // 一个割点可能会被多个点双共享
                    //  int z = -1;
                    //    do {
                    //        z = stack[--top];
                    //      dcc[dcc_cnt].add(z);
                    //    } while(z != v);
                    //   dcc[dcc_cnt].add(u);
                }

            }

        }
    }
    int gd = 0;
    int id =-1;
    int scc_cnt = 0;
    int sccno[];
    // 有向图的强连通分量
    void tarjan(int u) {
        int stk[] = new int[10001];
        //   int tptk[] = new int[10001];

        //  int fatk[] = new int[10001];
        int p  =1; stk[0] = u;//fatk[0] =-1;
        ot:while(p>0) {
            u  = stk[p-1];
            //  int fa  = fatk[p-1];
            if (dfn[u] == 0) {
                low[u] = dfn[u] = ++deep;
                stack[top++] = u;

            }

            for (; hc[u] != -1; hc[u] = ne[hc[u]]) {
                int v = to[hc[u]];
                if (dfn[v] == 0) {
                    stk[p++] = v;
                    continue ot;
                    //  low[u] = Math.min(low[u], low[v]);
                } else if (sccno[v] == 0) {
                    // dfn>0 but sccno==0, means it's in current stack
                    low[u] = Math.min(low[u], low[v]);
                }
            }

            p--;
            if (dfn[u] == low[u]) {
                sccno[u] = ++scc_cnt;
                if(u==1){
                    id = scc_cnt;
                }

                while (stack[top - 1] != u) {
                    sccno[stack[top - 1]] = scc_cnt;
                    if(stack[top - 1]==1){
                        id = scc_cnt;
                    }
                    --top;
                }

                --top;
            }
            if(p>=1){
                int fa = stk[p-1];
                low[fa] = Math.min(low[fa], low[u]);
            }
        }
    }
    int rr =0;
//    void solve() {
//
//    }

//    int get_room(int i,int j){
//        return i/3*3 + j/3;
//    }

//    int a[][] = new int[9][9];
//    int space = 0;
//
//    boolean vis_row[][] = new boolean[9][10];
//    boolean vis_col[][] = new boolean[9][10];
//    boolean vis_room[][] = new boolean[9][10];
//    int val[][][] =new int[9][9][];
//    int prepare[][];
//
//    void dfs(int rt){
//
//    }

    int h[],to[],ne[];int ct =0;
    void add(int u,int v){
        // u--;v--;
        to[ct] = v;
        ne[ct] = h[u];
        h[u] = ct++;

    }

    int dcc_cnt = 0;
    int time = 0;

    private static double f(double x) {
        return Math.pow(Math.abs(x), 0.5) + (5*(Math.pow(x, 3)));
    }

    long summ[];
    int v[];
    int hc[];
    void solve() {
//        File f = new File("C:\\Users\\Luqi\\Desktop\\1.png");
//        BufferedImage bi = null;
//        try {
//            bi = ImageIO.read(f);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//
//        int width = bi.getWidth();
//        int height = bi.getHeight();
List<Integer> r = new ArrayList<>();
        while(true){
            int x  =ni();
            if(lenbuf==-1) break;
            r.add(x);
        }

        for(int i=r.size()-1;i>=0;--i){
            int x = r.get(i);
            double y = f(x);
            if( y < 400.0) {
                System.out.printf("f(%d) = %.2f\n", x, y);
            } else {
                System.out.printf("f(%d) = %s\n", x, "MAGNA NIMIS!");
            }
        }

      //  println(width);
//      //  println(height);
//        int i  =ni();
//        int j  =ni();

//        for(int i=0;i<height;++i){
//            for(int j=0;j<width;++j){
//               int me =  bi.getRGB(i,j);
//               print(me==-1?0:1);
//            }
//            println();
//        }

//        int minx = bi.getMinX();
//        int miny = bi.getMinY();
//        System.out.println("width=" + width + ",height=" + height + ".");
//        System.out.println("minx=" + minx + ",miniy=" + miny + ".");
//        int b[][][] = new int[64][64][3];
//
//        for (int i = minx; i < width; i++) {
//            for (int j = miny; j < height; j++) {
//                int pixel = bi.getRGB(i, j);
//              //  print(pixel);
//               // b[j][i] = pixel;
//
//                b[j][i][0] = (pixel & 0xff0000) >> 16;
//                b[j][i][1] = (pixel & 0xff00) >> 8;
//                b[j][i][2] = (pixel & 0xff);
//
//            }
//            println();
//        }
//
//        for(int i=0;i<64;++i){
//            print("\"");
//            for(int j=0;j<64;++j){
//                print(b[i][j][0]<=50?"*":" ");
//            }
//            println("\",");
//        }
//        //println(b[0][0]);

//
//
//
//
//
//            }
//        }
    //    print("No");

//        int n = ni();
//        int m  = n*(n+1)/2;
//        int k = ni();
//        int p = 0;
//
//        double x[] = new double[n];
//        double y[] = new double[n];
//
//        for(int i=0;i<n;++i){
//            x[i] = nd();
//            y[i] = nd();
//        }
//
//        List<Item> li = new ArrayList<>();
//        for(int i=0;i<n;++i){
//            for(int j=i+1;j<n;++j){
//               double r =  (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
//               li.add(new Item(r,i,j));
//            }
//        }
//        Collections.sort(li,(xx,yy)->Double.compare(xx.s,yy.s));
//
//        init(n + 1);
//
//        int s = 0;
//        int c = n;
//        for (int i = 0; i < li.size(); ++i) {
//            int p1 = li.get(i).a;
//            int p2 = li.get(i).b;
//            if (root(p1) != root(p2)) {
//                combine(p1, p2);
//                c--;
//                if(c==k-1){
//                    print(roundS(Math.sqrt(li.get(i).s),2));
//                    break;
//                }
//            }
//        }

    }
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//    }

    static long mul(long a, long b, long p)
    {
        long res=0,base=a;
        while(b>0)
        {
            if((b&1L)>0)
                res=(res+base)%p;
            base=(base+base)%p;
            b>>=1;
        }
        return res;
    }

    static long mod_pow(long k,long n,long p){
        long res = 1L;
        long temp = (k%p+p)%p;
        while(n!=0L){
            if((n&1L)==1L){
                res = ((res*temp)%p+p)%p;
            }
            temp = ((temp * temp)%p+p)%p;
            n = n>>1L;
        }
        return res%p;
    }
    public static String roundS(double result, int scale){
        String fmt = String.format("%%.%df", scale);
        return String.format(fmt, result);
    }

//    void solve() {
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                int v = ni();
//                a[i][j] = v;
//                if(v>0) {
//                    vis_row[i][v] = true;
//                    vis_col[j][v] = true;
//                    vis_room[get_room(i, j)][v] = true;
//                }else{
//                    space++;
//                }
//            }
//        }
//
//
//        prepare = new int[space][2];
//
//        int p = 0;
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                if(a[i][j]==0){
//                    prepare[p][0] = i;
//                    prepare[p][1]= j;p++;
//                    List<Integer> temp =new ArrayList<>();
//                    for(int k=1;k<=9;++k){
//                        if(!vis_col[j][k]&&!vis_row[i][k]&&!vis_room[get_room(i,j)][k]){
//                            temp.add(k);
//                        }
//                    }
//                    int sz = temp.size();
//                    val[i][j] = new int[sz];
//                    for(int k=0;k<sz;++k){
//                        val[i][j][k] = temp.get(k);
//                    }
//                }
//            }
//        }
//        Arrays.sort(prepare,(x,y)->{
//           return Integer.compare(val[x[0]][x[1]].length,val[y[0]][y[1]].length);
//        });
//        dfs(0);
//
//
//
//
//
//
//
//
//
//
//    }

    InputStream is;
    PrintWriter out;

    void run() throws Exception {
        //is = new FileInputStream(new File("C:\\Users\\Luqi\\Downloads\\P3387_9.in"));
        is = System.in;
        out = new PrintWriter(System.out);

        solve();
        out.flush();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private char ncc() {
        int b = readByte();
        return (char) b;
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private String nline() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!isSpaceChar(b) || b == ' ') {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[][] nm(int n, int m) {
        char[][] a = new char[n][];
        for (int i = 0; i < n; i++) a[i] = ns(m);
        return a;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private long[] nal(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nl();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = (num << 3) + (num << 1) + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = num * 10 + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    void print(Object obj) {
        out.print(obj);
    }

    void println(Object obj) {
        out.println(obj);
    }

    void println() {
        out.println();
    }

    void printArray(int a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }

    void printArray(long a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }
}

import java.io.*;
import java.util.StringTokenizer;
import java.util.*;
import java.math.*;
import java.lang.Integer;

public class Solution {

	public static void main(String[] args) throws Exception {
		FastScanner cin = new FastScanner(System.in);

		int[] arr= new int[11];

		for (int i = 0; i < 11; i++) {
			arr[i]=cin.nextInt();
		}

		double f= 0;
		for (int i = 0; i < 11; i++) {
			f=Math.sqrt(Math.abs(arr[10-i]))+5*Math.pow(arr[10-i],3);
			System.out.print("f("+arr[10-i]+") = ");
			if (f<400) {
				System.out.printf("%.2f\n",f);
			} else {
				System.out.print("MAGNA NIMIS!\n");
			}
		}

	}

	static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.abs;
import static java.lang.Math.pow;
import static java.lang.Math.sqrt;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.StringTokenizer;

public class G {

	static void solve() throws Exception {
		int a[] = new int[11];
		for (int i = 0; i < 11; i++) {
			a[i] = scanInt();
		}
		for (int i = 10; i >= 0; i--) {
			double r = sqrt(abs(a[i])) + pow(a[i], 3) * 5;
			if (r > 400) {
				out.print("f(" + a[i] + ") = MAGNA NIMIS!\n");
			} else {
				out.printf(Locale.US, "f(%d) = %.2f\n", a[i], r);
			}
		}
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        GLinguaRomana solver = new GLinguaRomana();
        solver.solve(1, in, out);
        out.close();
    }

    static class GLinguaRomana {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int[] a = in.nextIntArray(11);
            for (int i = 10; i >= 0; i--) {
                double res = Math.sqrt(Math.abs(a[i])) + Math.pow(a[i], 3) * 5;
                out.print("f(" + a[i] + ") = ");
                if (res <= 400) {
                    out.printf("%.2f\n", res);
                } else {
                    out.printf("MAGNA NIMIS!\n");
                }
            }
        }

    }

    static class FastScanner {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int[] nextIntArray(int n) {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }

    }
}

// Imports
import java.util.*;
import java.io.*;

public class roman {

    /**
     * @param args the command line arguments
     * @throws IOException, FileNotFoundException
     */
    public static void main(String[] args) throws IOException, FileNotFoundException {

        // TODO UNCOMMENT WHEN ALGORITHM CORRECT
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));

        Stack<Integer> stk = new Stack<>();

        // TODO code application logic here
        for(int i = 0; i < 11; i++) {
            stk.push(Integer.parseInt(f.readLine()));
        }

        for(int i = 0; i < 11; i++) {
            int var = stk.pop();
            double v1 = Math.sqrt(Math.abs(var));
            double v2 = Math.pow(var, 3)*5;
            double v3 = Math.round((v1 + v2)*100)/100.0;
            if(v3 >= 400) {
                System.out.println("f(" + var + ") = MAGNA NIMIS!");
            }
            else {
                if(v3 - Math.round(v3*10)/10.0 == 0) {
                    System.out.println("f(" + var + ") = " + v3 + "0");
                }
                else {
                    System.out.println("f(" + var + ") = " + v3);
                }
            }
        }
    }

}

//package afc2020;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class G {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		List<Integer> ins = new ArrayList<>();
		for(int i = 0;i < 11;i++) {
			ins.add(ni());
		}
		for(int i = ins.size()-1;i >= 0;i--) {
			double x = ins.get(i);
			double ans = x*x*x*5.0 + Math.sqrt(Math.abs(x));
			if(ans > 400) {
				out.printf("f(%d) = MAGNA NIMIS!\n", ins.get(i), ans);
			}else {
				out.printf("f(%d) = %.2f\n", ins.get(i), ans);
			}
		}
	}

	void run() throws Exception
	{
		in = oj ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new G().run();
	}

	int ni() { return Integer.parseInt(in.next()); }
	long nl() { return Long.parseLong(in.next()); }
	double nd() { return Double.parseDouble(in.next()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

import java.io.*;
import java.util.*;
import java.math.*;

public class main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st, st2;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;
    public static long LINF = 0x3f3f3f3f3f3f3f3fL;

    public static void main(String[] args) throws Exception {
        int[] A = new int[11];
        for (int i = 0; i < 11; i++) {
            A[i] = Integer.parseInt(br.readLine());
        }

        for (int i = 10; i >= 0; i--) {
            double a = Math.pow(Math.abs(A[i]), 0.5);
            double b = Math.pow(A[i], 3) * 5;
            double res = a + b;

            if (res > 400) {
                System.out.printf("f(%d) = MAGNA NIMIS!\n", A[i]);
            } else {
                System.out.printf("f(%d) = %.2f\n", A[i], res);
            }
        }

        pw.close();
        br.close();
    }
}

class Pair implements Comparable<Pair>{
    public int a, b;

    Pair(int _a, int _b){
        a = _a;
        b = _b;
    }

    public String toString(){
        return a + " " + b;
    }

    public int compareTo(Pair p){
        if (a != p.a) return a < p.a ? -1 : 1;
        if (b != p.b) return b < p.b ? -1 : 1;
        return 0;
    }
}

import java.io.*;
import java.util.*;
import java.math.*;
import java.text.*;

public class G {

	public void realMain() throws Exception {

		BufferedReader fin = new BufferedReader(new InputStreamReader(System.in), 1000000);

		String in = fin.readLine();

		ArrayList<Integer> al = new ArrayList<Integer>();

		while(in != null && in.length() > 0) {
			al.add(Integer.parseInt(in));

			in = fin.readLine();
		}

		for(int i = al.size() - 1; i >= 0; i--) {
			double aresult = Math.pow(Math.abs(al.get(i)), .5);
			double bresult = Math.pow(al.get(i), 3) * 5;

			double result = aresult + bresult;

			if(result > 400) {
				System.out.println("f(" + al.get(i) + ") = MAGNA NIMIS!");
			} else {
				DecimalFormat format = new DecimalFormat("0.00");
				System.out.println("f(" + al.get(i) + ") = " + format.format(result));
			}
		}

	}

	public static void main(String[] args) throws Exception {
		G f = new G();
		f.realMain();
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class G {
    private void work() {
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in), 1 << 16));
        int[] a = new int[11];
        for (int i = 0; i < 11; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        double[] f = new double[11];

        for (int i = 10; i >= 0; i--) {
            System.out.printf("f(%d) = ", a[i]);
            double x = a[i] * a[i] * a[i] * 5 + Math.sqrt(Math.abs(a[i]));
            if (x > 400) {
                System.out.println("MAGNA NIMIS!");
            } else {
                System.out.printf("%.2f\n", x);
            }
        }
    }

    public static void main(String[] args) {
        new G().work();
    }
}

import java.util.*;
public class g {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		Stack<Integer> s=new Stack<>();
		for(int i=0;i<11;i++)s.push(in.nextInt());
		while(!s.isEmpty()) {
			int on=s.pop();
			double a = Math.sqrt(Math.abs(on));
			double b = on*on*on*5;
			double r=a + b;
			if (r > 400)System.out.printf("f(%d) = MAGNA NIMIS!\n", on);
			else System.out.printf("f(%d) = %.2f\n", on,r);
		}
	}

}

import java.util.*;
import java.io.*;

public class TPKA {
	public static void main(String... args) {
		int[] input = new int[11];
		int userInput = 0;
		Scanner in = new Scanner(System.in);
		for(int i = 0; i < 11; i++) {
			String s = in.nextLine();
			try {
				userInput = Integer.parseInt(s);
			} catch (NumberFormatException e) {
				System.out.println("You entered invalid input, exiting");
				System.exit(1);
			}
			input[i] = userInput;
		}
		for(int j = 10; j >= 0; j--) {
			int x = input[j]; double y = f(x);
			if( y < 400.0) {
				System.out.printf("f(%d) = %.2f\n", x, y);
			} else {
				System.out.printf("f(%d) = %s\n", x, "MAGNA NIMIS!");
			}
		}
	}

	private static double f(double x) {
		return Math.pow(Math.abs(x), 0.5) + (5*(Math.pow(x, 3)));
	}
}

import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here
        Scanner scan= new Scanner(System.in);
        double varum [] =  new double[11];

        for (int i = 0 ; i<11 ; i++){
            double a = scan.nextInt();
            varum[i] = a;
        }

        for (int i = 10 ; i>=0 ; i--){

            double a = varum[i] ;
            double are = Math.abs(a);
         //   System.out.println(are);
            are = Math.sqrt(are);
        //    System.out.println(are);
            double bre = Math.pow(a, 3.0);
            bre = bre*5;
            double resul = are+bre;

            if (400 < resul){
               System.out.print("f(");
                System.out.printf("%.0f", a);
                System.out.println( ")" + " = MAGNA NIMIS!");

            }
            else {
                System.out.print("f(");
                System.out.printf("%.0f", a);
                System.out.print( ")" + " = ");

                System.out.printf("%.2f", resul);
                System.out.println("");
            }

        }

    }
}

// Imports
import java.util.*;
import java.io.*;

public class roman {

    /**
     * @param args the command line arguments
     * @throws IOException, FileNotFoundException
     */
    public static void main(String[] args) throws IOException, FileNotFoundException {

        // TODO UNCOMMENT WHEN ALGORITHM CORRECT
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));

        Stack<Integer> stk = new Stack<>();

        // TODO code application logic here
        for(int i = 0; i < 11; i++) {
            stk.push(Integer.parseInt(f.readLine()));
        }

        for(int i = 0; i < 11; i++) {
            int var = stk.pop();
            double v1 = Math.sqrt(Math.abs(var));
            double v2 = Math.pow(var, 3)*5;
            double v3 = Math.round((v1 + v2)*100)/100.0;
            if(v3 > 400) {
                System.out.println("f(" + var + ") = MAGNA NIMIS!");
            }
            else {
                if(v3 - Math.floor(v3) == 0) {
                    System.out.println("f(" + var + ") = " + v3 + "0");
                }
                else {
                    System.out.println("f(" + var + ") = " + v3);
                }
            }
        }
    }

}

// Imports
import java.util.*;
import java.io.*;

public class roman {

    /**
     * @param args the command line arguments
     * @throws IOException, FileNotFoundException
     */
    public static void main(String[] args) throws IOException, FileNotFoundException {

        // TODO UNCOMMENT WHEN ALGORITHM CORRECT
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));

        Stack<Integer> stk = new Stack<>();

        // TODO code application logic here
        for(int i = 0; i < 11; i++) {
            stk.push(Integer.parseInt(f.readLine()));
        }

        for(int i = 0; i < 11; i++) {
            double var = stk.pop();
            double v1 = Math.sqrt(Math.abs(var));
            double v2 = Math.pow(var, 3)*5;
            double v3 = Math.round((v1 + v2)*100)/100.0;
            if(v3 > 400) {
                System.out.println("f(" + var + ") = MAGNA NIMIS!");
            }
            else {
                if(v3 - Math.floor(v3) == 0) {
                    System.out.println("f(" + var + ") = " + v3 + "0");
                }
                else {
                    System.out.println("f(" + var + ") = " + v3);
                }
            }
        }
    }

}

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String... args) {
        double[] input = new double[11];
        double userInput = 0.0;
        Scanner in = new Scanner(System.in);
        for(int i = 0; i < 11; i++) {
            System.out.print("Please enter a number: ");
            String s = in.nextLine();
            try {
                userInput = Double.parseDouble(s);
            } catch (NumberFormatException e) {
                System.out.println("You entered invalid input, exiting");
                System.exit(1);
            }
            input[i] = userInput;
        }
        for(int j = 10; j >= 0; j--) {
            double x = input[j]; double y = f(x);
            if( y < 400.0) {
                System.out.printf("f( %.2f ) = %.2f\n", x, y);
            } else {
                System.out.printf("f( %.2f ) = %s\n", x, "TOO LARGE");
            }
        }
    }

    private static double f(double x) {
        return Math.pow(Math.abs(x), 0.5) + (5*(Math.pow(x, 3)));
    }
}

import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here
        Scanner scan= new Scanner(System.in);
        double varum [] =  new double[11];

        for (int i = 0 ; i<11 ; i++){
            double a = scan.nextInt();
            varum[i] = a;
        }

        for (int i = 10 ; i>=0 ; i--){

            double a = varum[i] ;
            double are = Math.abs(a);
         //   System.out.println(are);
            are = Math.sqrt(are);
        //    System.out.println(are);
            double bre = Math.pow(a, 3.0);
            bre = bre*5;
            double resul = are+bre;

            if (a < resul && a!=1){
               System.out.print("f(");
                System.out.printf("%.0f", a);
                System.out.println( ")" + " = MAGNA NIMIS!");

            }
            else {
                System.out.print("f(");
                System.out.printf("%.0f", a);
                System.out.print( ")" + " = ");

                System.out.printf("%.2f", resul);
                System.out.println("");
            }

        }

    }
}

//package afc2020;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class G {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		List<Integer> ins = new ArrayList<>();
		while(in.hasNext()) {
			ins.add(ni());
		}
		Collections.sort(ins, (x, y) -> (Math.abs(x) - Math.abs(y)));
		for(int i = ins.size()-1;i >= 0;i--) {
			double x = ins.get(i);
			double ans = x*x*x*5.0 + Math.sqrt(Math.abs(x));
			if(Math.abs(ans) >= 4000) {
				out.printf("f(%d) = MAGNA NIMIS!\n", ins.get(i));
			}else {
				out.printf("f(%d) = %.2f\n", ins.get(i), ans);
			}
		}
	}

	void run() throws Exception
	{
		in = oj ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new G().run();
	}

	int ni() { return Integer.parseInt(in.next()); }
	long nl() { return Long.parseLong(in.next()); }
	double nd() { return Double.parseDouble(in.next()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

//package afc2020;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class G {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		List<Integer> ins = new ArrayList<>();
		for(int i = 0;i < 11;i++) {
			ins.add(ni());
		}
		for(int i = ins.size()-1;i >= 0;i--) {
			double x = ins.get(i);
			double ans = x*x*x*5.0 + Math.sqrt(Math.abs(x));
			if(Math.abs(ans) >= 5000) {
				out.printf("f(%d) = MAGNA NIMIS!\n", ins.get(i), ans);
			}else {
				out.printf("f(%d) = %.2f\n", ins.get(i), ans);
			}
		}
	}

	void run() throws Exception
	{
		in = oj ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new G().run();
	}

	int ni() { return Integer.parseInt(in.next()); }
	long nl() { return Long.parseLong(in.next()); }
	double nd() { return Double.parseDouble(in.next()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

//package afc2020;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class G {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		List<Integer> ins = new ArrayList<>();
		for(int i = 0;i < 11;i++) {
			ins.add(ni());
		}
		for(int i = ins.size()-1;i >= 0;i--) {
			double x = ins.get(i);
			double ans = x*x*x*5.0 + Math.sqrt(Math.abs(x));
			if(400*ans > 4000) {
				out.printf("f(%d) = MAGNA NIMIS!\n", ins.get(i), ans);
			}else {
				out.printf("f(%d) = %.2f\n", ins.get(i), ans);
			}
		}
	}

	void run() throws Exception
	{
		in = oj ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new G().run();
	}

	int ni() { return Integer.parseInt(in.next()); }
	long nl() { return Long.parseLong(in.next()); }
	double nd() { return Double.parseDouble(in.next()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

//package afc2020;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class G {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		List<Integer> ins = new ArrayList<>();
		while(in.hasNext()) {
			ins.add(ni());
		}
		for(int i = ins.size()-1;i >= 0;i--) {
			double x = ins.get(i);
			double ans = x*x*x*5.0 + Math.sqrt(Math.abs(x));
			if(Math.abs(ans) >= 4000) {
				out.printf("f(%d) = MAGNA NIMIS!\n", ins.get(i));
			}else {
				out.printf("f(%d) = %.2f\n", ins.get(i), ans);
			}
		}
	}

	void run() throws Exception
	{
		in = oj ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new G().run();
	}

	int ni() { return Integer.parseInt(in.next()); }
	long nl() { return Long.parseLong(in.next()); }
	double nd() { return Double.parseDouble(in.next()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

//package afc2020;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class G {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		List<Integer> ins = new ArrayList<>();
		for(int i = 0;i < 11;i++) {
			ins.add(ni());
		}
		for(int i = ins.size()-1;i >= 0;i--) {
			double x = ins.get(i);
			double ans = x*x*x*5.0 + Math.sqrt(Math.abs(x));
			if(ans >= 4000) {
				out.printf("f(%d) = MAGNA NIMIS!\n", ins.get(i), ans);
			}else {
				out.printf("f(%d) = %.2f\n", ins.get(i), ans);
			}
		}
	}

	void run() throws Exception
	{
		in = oj ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new G().run();
	}

	int ni() { return Integer.parseInt(in.next()); }
	long nl() { return Long.parseLong(in.next()); }
	double nd() { return Double.parseDouble(in.next()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

import java.io.*;
import java.util.StringTokenizer;
import java.util.*;
import java.math.*;
import java.lang.Integer;

public class Solution {

	public static void main(String[] args) throws Exception {
		FastScanner cin = new FastScanner(System.in);

		int[] arr= new int[11];

		for (int i = 0; i < 11; i++) {
			arr[i]=cin.nextInt();
		}

		double f= 0;
		for (int i = 0; i < 11; i++) {
			f=Math.sqrt(Math.abs(arr[10-i]))+5*Math.pow(arr[10-i],3);
			System.out.print("f("+arr[10-i]+") = ");
			if (f<5000) {
				System.out.printf("%.2f\n",f);
			} else {
				System.out.print("MAGNA NIMIS!\n");
			}
		}

	}

	static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}

//package afc2020;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class G {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		List<Integer> ins = new ArrayList<>();
		for(int i = 0;i < 11;i++) {
			ins.add(ni());
		}
		for(int i = ins.size()-1;i >= 0;i--) {
			double x = ins.get(i);
			double ans = x*x*x*5.0 + Math.sqrt(Math.abs(x));
			if(ans > 400*Math.abs(x)) {
				out.printf("f(%d) = MAGNA NIMIS!\n", ins.get(i), ans);
			}else {
				out.printf("f(%d) = %.2f\n", ins.get(i), ans);
			}
		}
	}

	void run() throws Exception
	{
		in = oj ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new G().run();
	}

	int ni() { return Integer.parseInt(in.next()); }
	long nl() { return Long.parseLong(in.next()); }
	double nd() { return Double.parseDouble(in.next()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}