//HAM JING YI A19EC0048
#include<iostream>
using namespace std;

class B
{
	private:
		int m; //a
		
	protected:
		int n; //b
	
	public:
		void setM (int M) //c
		{
			m=M;
		}
		void setN (int N) //c
		{
			n=N;
		}
		int getM() const  //c
		{
			return m;
		}
		int getN() const  //c
		{
			return n;
		}
		virtual float calc() //d
		{
			return m*n;
		}
};

class D : public B
{
	protected:
		float q;  //a
		float r;  //b
	
	public:
		void setQ (float Q)  //c
		{
			q=Q;
		}
		void setR (float R)  //c
		{
			r=R;
		}
		float getQ() const  //c
		{
			return q;
		}
		float getR() const //c
		{
			return r;
		}
		float calc()  //d
		{
			return q*r;
		}
};
