Alice has got addicted to a game called Sirtet recently.In Sirtet, player is given an $$$n \times m$$$ grid. Initially $$$a_{i,j}$$$ cubes are stacked up in the cell $$$(i,j)$$$. Two cells are called adjacent if they share a side. Player can perform the following operations:   stack up one cube in two adjacent cells;  stack up two cubes in one cell. Cubes mentioned above are identical in height.Here is an illustration of the game. States on the right are obtained by performing one of the above operations on the state on the left, and grey cubes are added due to the operation.  Player's goal is to make the height of all cells the same (i.e. so that each cell has the same number of cubes in it) using above operations. Alice, however, has found out that on some starting grids she may never reach the goal no matter what strategy she uses. Thus, she is wondering the number of initial grids such that   $$$L \le a_{i,j} \le R$$$ for all $$$1 \le i \le n$$$, $$$1 \le j \le m$$$;  player can reach the goal using above operations. Please help Alice with it. Notice that the answer might be large, please output the desired value modulo $$$998,244,353$$$.

Output one integer, representing the desired answer modulo $$$998,244,353$$$.

NoteIn the first sample, the only initial grid that satisfies the requirements is $$$a_{1,1}=a_{2,1}=a_{1,2}=a_{2,2}=1$$$. Thus the answer should be $$$1$$$.In the second sample, initial grids that satisfy the requirements are $$$a_{1,1}=a_{1,2}=1$$$ and $$$a_{1,1}=a_{1,2}=2$$$. Thus the answer should be $$$2$$$.

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EHeightAllTheSame solver = new EHeightAllTheSame();
        solver.solve(1, in, out);
        out.close();
    }

    static class EHeightAllTheSame {
        long mod = 998244353;

        long countOdd(long L, long R) {
            long N = (R - L) / 2;
            if (R % 2 != 0 || L % 2 != 0)
                N += 1;
            return N;
        }

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            long n = in.scanInt();
            long m = in.scanInt();
            long l = in.scanInt();
            long r = in.scanInt();
            long prod = (n * m);
            long ct_odd = countOdd(l, r);
            long ct_even = r - l + 1 - ct_odd;
            if (prod % 2 == 0) {
                long ans = (CodeHash.pow((ct_even - ct_odd + mod) % mod, prod, mod) + CodeHash.pow((ct_even + ct_odd) % mod, prod, mod)) % mod;
                ans = (ans * CodeHash.modInverse(2, mod)) % mod;
                out.println(ans);
            } else {
                long t1 = (-CodeHash.pow((ct_even - ct_odd + mod) % mod, prod, mod) + CodeHash.pow((ct_even + ct_odd) % mod, prod, mod) + mod) % mod;
                t1 = (t1 * CodeHash.modInverse(2, mod)) % mod;
                long t2 = (-CodeHash.pow((ct_odd - ct_even + mod) % mod, prod, mod) + CodeHash.pow((ct_even + ct_odd) % mod, prod, mod) + mod) % mod;
                t2 = (t2 * CodeHash.modInverse(2, mod)) % mod;
                out.println((t1 + t2) % mod);
            }
        }

    }

    static class CodeHash {
        public static long[] euclidExtended(long a, long b) {
            if (b == 0) {
                long ar[] = new long[]{1, 0};
                return ar;
            }
            long ar[] = euclidExtended(b, a % b);
            long temp = ar[0];
            ar[0] = ar[1];
            ar[1] = temp - (a / b) * ar[1];
            return ar;
        }

        public static long modInverse(long a, long m) {
            long ar[] = euclidExtended(a, m);
            return ((ar[0] % m) + m) % m;
        }

        public static long pow(long a, long b, long m) {
            long res = 1;
            a %= m;
            while (b > 0) {
                if ((b & 1) == 1) res = (res * a) % m;
                a = (a * a) % m;
                b >>= 1;
            }
            return res;
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}

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

/**
 * Created by Katushka on 11.03.2020.
 */
public class B {
    static int[] readArray(int size, InputReader in) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = in.nextInt();
        }
        return a;
    }

    static long[] readLongArray(int size, InputReader in) {
        long[] a = new long[size];
        for (int i = 0; i < size; i++) {
            a[i] = in.nextLong();
        }
        return a;
    }

    final static long MOD = 998244353;

    private static long fastPow(long x, long y) {
        if (x == 1) {
            return 1;
        }
        if (y == 0) {
            return 1;
        }
        long p = fastPow(x, y / 2) % MOD;
        p = p * p % MOD;
        if (y % 2 == 1) {
            p = p * x % MOD;
        }
        return p;
    }

    private static long obrat2() {
        return fastPow(2, MOD - 2);
    }

    public static void main(String[] args) throws FileNotFoundException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        long n = in.nextInt();
        long m = in.nextInt();
        long l = in.nextInt();
        long r = in.nextInt();
        if (n % 2 != 0 && m % 2 != 0) {
            out.println(fastPow((r - l + 1), n * m));
        } else {
            long res1 = fastPow((r - l + 1), n * m - 1);
            long res;
            if ((r - l + 1) % 2 == 0) {
                res = res1 * ((r - l + 1) / 2) % MOD;
            } else {
                res = (res1 * ((r - l + 2) / 2) % MOD + MOD - (res1 + MOD - 1) % MOD * obrat2() % MOD) % MOD;
            }
            out.println(res);
        }

        out.close();
    }

    private static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public String nextString() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

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

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

        public char nextChar() {
            return next().charAt(0);
        }
    }
}

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

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }

    long mod=998244353;

    void solve() throws IOException {
        long n=nl(),m=nl(),a=nl(),b=nl();
        long t=n*m;
        if (t%2==1) {
            out.println(mp(b-a+1,t));
        }
        else {
            long ans=mp(b-a+1,t);
            //out.println(ans);
            if ((b-a+1)%2==1) ans=(ans+1)%mod;
            //out.println(ans);
            ans=(ans*mp(2,mod-2))%mod;
            out.println(ans);
        }
        out.flush();
    }

    long mp(long a,long p) {
        long r=1;
        while (p>0) {
            if ((p&1)>0) r=(r*a)%mod;
            p=p>>1;
            a=(a*a)%mod;
        }
        return r;
    }

    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

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

public class S{
   static class Pair implements Comparable<Pair>{
   int a;
   int b;
   public Pair(int x,int y){a=x;b=y;}
   public Pair(){}
   public int compareTo(Pair p1){
       if(a == p1.a)
       return b - p1.b;
       return a - p1.a;
   }
 }
static class TrieNode{
  TrieNode[]child;
  int w;
  boolean term;
  TrieNode(){
    child = new TrieNode[26];
  }
}
  public static int gcd(int a,int b)
  {
    if(a<b)
      return gcd(b,a);
    if(b==0)
      return a;
    return gcd(b,a%b);

  }
  //static long ans = 0;
  static long mod = 998244353;

    public static void main(String[] args) throws Exception {
       new Thread(null, null, "Anshum Gupta", 99999999) {
            public void run() {
                try {
                    solve();
                } catch(Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }
static long[][]dp;
static int maxV;
static long pow(long x,long y){
    if(y == 0)return 1;
    if(y==1)return x;
    long a = pow(x,y/2);
    a = (a*a)%mod;
    if(y%2==0){
        return a;
    }
    return (a*x)%mod;
}
static void dfs
(ArrayList<ArrayList<Integer>>adj,int sv,boolean[]vis,int[]x){}
static TrieNode root;
 public static void solve() throws Exception {
   // solve the problem here
   MyScanner s = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int t = 1;//s.nextInt();
        int tc = 0;
      //  maxV = 300000;
        while(tc++<t){
            long n = s.nextInt();
            long m = s.nextInt();
            int l = s.nextInt();
            int r = s.nextInt();
            int e = (r-l+1)/2;
            int o = (r-l+1) - (r-l+1)/2;
            long tt = r-l+1;
            if((n*m)%2!=0)
            {
                out.println(pow(tt,m*n));
            }
            else{
                long x = (pow(e+o,m*n) - pow(Math.abs(e-o),m*n))%mod;
                x = (x+mod)%mod;

                x = (x*pow(2,mod-2))%mod;
             ////   out.println(pow(2,mod-2));

                long ans = (pow(tt,m*n) - x)%mod;
                if(ans < 0)ans+=mod;
                ans%=mod;
                out.println(ans);
            }
        }
        out.flush();
}

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

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

public class Solution{
	long mod = 998244353L;

	public void solve(int test, Scanner sc){
		long n = sc.nextLong();
		long m = sc.nextLong();
		long l = sc.nextLong();
		long r = sc.nextLong();

		long total = power(r-l+1L, n*m);

		if((n*m)%2 == 1){
			System.out.println(total);
		}
		else{
			if((r-l+1L)%2 == 1){
				total++;
				total%=mod;
			}
			total *= modInverse(2L);
			total %= mod;
			System.out.println(total);
		}
	}

	public long power(long a, long b){
		if(b == 0){
			return 1L;
		}

		if(b%2 == 0){
			return power(((a*a)%mod), b/2L);
		}
		else{
			return ((power(((a*a)%mod), b/2L)*a)%mod);
		}
	}

	public long modInverse(long a){
		return power(a, mod-2L);
	}

	public Solution(){
		Scanner sc = new Scanner(System.in);
		int tests = 1;

        for(int t=1; t<=tests; t++){
			solve(t, sc);
        }
	}

	public static void main(String[] args){
		new Solution();
	}
}

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

public class E {
	public static void main(String[] args) throws Exception {
		new E().run();
	}
	public void run() throws Exception {
		FastScanner f = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = f.nextInt();
		int m = f.nextInt();
		int l = f.nextInt();
		int r = f.nextInt();
		if(n % 2 == 1 && m % 2 == 1) {
			out.println(exp(exp(r-l+1, n), m));
			out.flush();
			return;
		}
		int even = r/2-(l+1)/2+1;
		int odd = r-l+1-even;
		long[][] mat = {{even, odd},{odd, even}};
		mat = exp(mat, n);
		mat = exp(mat, m);
		out.println(mat[0][0]);
///
		out.flush();
	}
	public int MOD = 998_244_353;
	public long[][] mult(long[][] a, long[][] b) {
		long[][] c = new long[a.length][b[0].length];
		for(int i = 0; i < a.length; i++)
			for(int j = 0; j < b[0].length; j++)
				for(int k = 0; k < b.length; k++)
					c[i][j] = (c[i][j] + a[i][k] * b[k][j] % MOD) % MOD;
		return c;
	}
	public long[][] exp(long[][] m, int e) {
		if(e == 1) return m;
		long[][] r = exp(m, e >> 1);
		r = mult(r, r);
		if(e%2 == 1)
			r = mult(r, m);
		return r;
	}
	public long exp(long a, int e) {
		if(e == 1) return a;
		long r = exp(a, e >> 1);
		r = r*r%MOD;
		if(e % 2 == 1)
			r = r*a % MOD;
		return r;
	}
///
    static class FastScanner {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public FastScanner() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
        public String nextLine() {
        	try {
        		return reader.readLine();
        	} catch(IOException e) {
        		throw new RuntimeException(e);
        	}
        }
    }
}

// https://codeforces.com/contest/1332/submission/74986306 (rainboy)
import java.io.*;
import java.util.*;

public class CF1332E extends PrintWriter {
	CF1332E() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1332E o = new CF1332E(); o.main(); o.flush();
	}

	static final int MD = 998244353;
	long power(int a, long k) {
		if (k == 0)
			return 1;
		long p = power(a, k / 2);
		p = p * p % MD;
		if (k % 2 == 1)
			p = p * a % MD;
		return p;
	}
	void mult(int[][] aa, int[][] bb, int[][] cc) {
		for (int i = 0; i < 2; i++)
			for (int j = 0; j < 2; j++) {
				long c = 0;
				for (int k = 0; k < 2; k++)
					c += (long) aa[i][k] * bb[k][j];
				cc[i][j] = (int) (c % MD);
			}
	}
	void power(int[][] aa, int[][] pp, int[][] tt, long k) {
		if (k == 0) {
			pp[0][0] = pp[1][1] = 1;
			pp[1][0] = pp[1][0] = 0;
			return;
		}
		if (k % 2 == 0) {
			power(aa, tt, pp, k / 2);
			mult(tt, tt, pp);
		} else {
			power(aa, pp, tt, k / 2);
			mult(pp, pp, tt);
			mult(tt, aa, pp);
		}
	}
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int r = sc.nextInt();
		int k = r - l + 1;
		long c = (long) n * m;
		long ans;
		if (n % 2 == 1 && m % 2 == 1)
			ans = power(k, c);
		else {
			int[][] aa = new int[2][2];
			int[][] pp = new int[2][2];
			int[][] tt = new int[2][2];
			int k0 = r / 2 - (l - 1) / 2, k1 = k - k0;
			aa[0][0] = aa[1][1] = k0;
			aa[0][1] = aa[1][0] = k1;
			power(aa, pp, tt, c);
			ans = pp[0][0];
		}
		println(ans);
	}
}

import java.io.*;
import java.util.*;
public class Main{
	static int mod=998244353;
	static long fastpow(long n,long ti) {
		 if (ti == 0)
		        return 1l;
		if(ti%2==0) {
			long y=fastpow(n, ti/2);
			long k=y*y;
			k%=mod;
			return k;
		}
		else {
			long y=fastpow(n, ti/2);
			long k=((n*y)%mod)*y;
			k%=mod;
			return k;
		}
	}
	static long modInv(long x) {
		return fastpow(x, mod-2);
	}
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		long n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt(),r=sc.nextInt();
		if(l==r) {
			pw.println(1);
			pw.flush();
			return;
		}

		long odds=((r+1)/2)-(l/2),evens=(r/2)-((l-1)/2);

		long ans;

		if((n*m)%2==1) {
			ans=fastpow(odds+evens, (n*m));
		}
		else {
			ans=(fastpow(odds+evens, (n*m))+fastpow(odds-evens, (n*m)))%mod;
			ans=(ans*modInv(2))%mod;
		}
		pw.println(ans);

		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;

/**
 * @author Nikita Gorokhov <wackloner@yandex-team.ru>
 */
public class E {

    private final static long MOD = 998244353;

    private long powByMod(long n, long p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }
        if (p % 2 == 0) {
            long half = powByMod(n, p / 2);
            return half * half % MOD;
        } else {
            return n * powByMod(n, p - 1) % MOD;
        }
    }

    private void solve() {
        long n = nextInt(), m = nextInt(), L = nextInt(), R = nextInt();

        if (n * m % 2 == 1) {
            long cnt = R - L + 1;
            out.println(powByMod(cnt, n * m));
        } else {
            long cnt = R - L + 1;
            long sum = powByMod(cnt, n * m);

            long div = powByMod(2, MOD - 2);
            if (cnt % 2 == 0) {
                out.println(sum * div % MOD);
            } else {
                out.println((sum +1 ) * div % MOD);
            }
        }

    }

    private final static String INPUT_FILENAME = "input.txt";
    private final static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private InputStream inputStream;
    private PrintWriter out;

    private void run() throws FileNotFoundException {
        inputStream = ONLINE_JUDGE ? System.in : new FileInputStream(INPUT_FILENAME);
        out = new PrintWriter(System.out);

        solve();

        out.flush();
    }

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

    private byte[] buffer = new byte[1024];
    private int bufferLen = 0, bufferPtr = 0;

    private int readByte() {
        if (bufferLen == -1) {
            throw new InputMismatchException();
        }
        if (bufferPtr >= bufferLen) {
            bufferPtr = 0;
            try {
                bufferLen = inputStream.read(buffer);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (bufferLen <= 0) {
                return -1;
            }
        }
        return buffer[bufferPtr++];
    }

    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 nextDouble() {
        return Double.parseDouble(next());
    }

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

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

    private int nextInt() {
        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 * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nextLong() {
        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();
        }
    }
}

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

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class cf1332e {

    static Map<Long, Integer> f = new HashMap<>(), g = new HashMap<>();

    public static void main(String[] args) throws IOException {
        int n = rni(), m = ni(), l = ni(), r = ni();
        long nm = (long) n * m;
        int N = r - l + 1, E = l % 2 == 0 ? (N + 1) / 2 : N / 2;
        f.put(0L, 1);
        f.put(1L, E % mmod);
        g.put(0L, 0);
        g.put(1L, (N - E) % mmod);
        prln(nm % 2 == 1 ? mpow(N, nm) : f(nm));
        close();
    }

    static int f(long n) {
        if (f.containsKey(n)) {
            return f.get(n);
        }
        f.put(n, madd(mmul(f(n / 2), f((n + 1) / 2)), mmul(g(n / 2), g((n + 1) / 2))));
        return f.get(n);
    }

    static int g(long n) {
        if (g.containsKey(n)) {
            return g.get(n);
        }
        g.put(n, madd(mmul(f(n / 2), g((n + 1) / 2)), mmul(g(n / 2), f((n + 1) / 2))));
        return g.get(n);
    }

    static int mmod = 998244353;

    static int madd(int a, int b) {
        return (a + b) % mmod;
    }

    static int madd(int... a) {
        int ans = a[0];
        for (int i = 1; i < a.length; ++i) {
            ans = madd(ans, a[i]);
        }
        return ans;
    }

    static int msub(int a, int b) {
        return (a - b + mmod) % mmod;
    }

    static int mmul(int a, int b) {
        return (int) ((long) a * b % mmod);
    }

    static int mmul(int... a) {
        int ans = a[0];
        for (int i = 1; i < a.length; ++i) {
            ans = mmul(ans, a[i]);
        }
        return ans;
    }

    static int minv(int x) {
        return mpow(x, mmod - 2);
    }

    static int mpow(int a, long b) {
        if (a == 0) {
            return 0;
        }
        int ans = 1;
        while (b > 0) {
            if ((b & 1) > 0) {
                ans = mmul(ans, a);
            }
            a = mmul(a, a);
            b >>= 1;
        }
        return ans;
    }

    static int mpow(int a, int b) {
        if (a == 0) {
            return 0;
        }
        int ans = 1;
        while (b > 0) {
            if ((b & 1) > 0) {
                ans = mmul(ans, a);
            }
            a = mmul(a, a);
            b >>= 1;
        }
        return ans;
    }

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // references
    // IBIG = 1e9 + 7
    // IMAX ~= 2e9
    // LMAX ~= 9e18

    // constants
    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;
    // math util
    static int minof(int a, int b, int c) {return min(a, min(b, c));}
    static int minof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); int min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static long minof(long a, long b, long c) {return min(a, min(b, c));}
    static long minof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); long min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static int maxof(int a, int b, int c) {return max(a, max(b, c));}
    static int maxof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); int max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static long maxof(long a, long b, long c) {return max(a, max(b, c));}
    static long maxof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); long max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static int powi(int a, int b) {if (a == 0) return 0; int ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static long powl(long a, int b) {if (a == 0) return 0; long ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static int fli(double d) {return (int) d;}
    static int cei(double d) {return (int) ceil(d);}
    static long fll(double d) {return (long) d;}
    static long cel(double d) {return (long) ceil(d);}
    static int gcf(int a, int b) {return b == 0 ? a : gcf(b, a % b);}
    static long gcf(long a, long b) {return b == 0 ? a : gcf(b, a % b);}
    static int lcm(int a, int b) {return a * b / gcf(a, b);}
    static long lcm(long a, long b) {return a * b / gcf(a, b);}
    static int randInt(int min, int max) {return __rand.nextInt(max - min + 1) + min;}
    static long mix(long x) {x += 0x9e3779b97f4a7c15L; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L; x = (x ^ (x >> 27)) * 0x94d049bb133111ebL; return x ^ (x >> 31);}
    // array util
    static void reverse(int[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {int swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(long[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {long swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(double[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {double swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(char[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {char swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void shuffle(int[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); int swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(long[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); long swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(double[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); double swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void rsort(int[] a) {shuffle(a); sort(a);}
    static void rsort(long[] a) {shuffle(a); sort(a);}
    static void rsort(double[] a) {shuffle(a); sort(a);}
    static int[] copy(int[] a) {int[] ans = new int[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static long[] copy(long[] a) {long[] ans = new long[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static double[] copy(double[] a) {double[] ans = new double[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static char[] copy(char[] a) {char[] ans = new char[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    // graph util
    static List<List<Integer>> g(int n) {List<List<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; ++i) g.add(new ArrayList<>()); return g;}
    static List<Set<Integer>> sg(int n) {List<Set<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; ++i) g.add(new HashSet<>()); return g;}
    static void c(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v); g.get(v).add(u);}
    static void cto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v);}
    static void dc(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v); g.get(v).remove(u);}
    static void dcto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v);}
    // input
    static void r() throws IOException {input = new StringTokenizer(rline());}
    static int ri() throws IOException {return Integer.parseInt(rline());}
    static long rl() throws IOException {return Long.parseLong(rline());}
    static double rd() throws IOException {return Double.parseDouble(rline());}
    static int[] ria(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni(); return a;}
    static int[] riam1(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni() - 1; return a;}
    static long[] rla(int n) throws IOException {long[] a = new long[n]; r(); for (int i = 0; i < n; ++i) a[i] = nl(); return a;}
    static double[] rda(int n) throws IOException {double[] a = new double[n]; r(); for (int i = 0; i < n; ++i) a[i] = nd(); return a;}
    static char[] rcha() throws IOException {return rline().toCharArray();}
    static String rline() throws IOException {return __in.readLine();}
    static String n() {return input.nextToken();}
    static int rni() throws IOException {r(); return ni();}
    static int ni() {return Integer.parseInt(n());}
    static long rnl() throws IOException {r(); return nl();}
    static long nl() {return Long.parseLong(n());}
    static double rnd() throws IOException {r(); return nd();}
    static double nd() {return Double.parseDouble(n());}
    static List<List<Integer>> rg(int n, int m) throws IOException {List<List<Integer>> g = g(n); for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1); return g;}
    static void rg(List<List<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1);}
    static List<List<Integer>> rdg(int n, int m) throws IOException {List<List<Integer>> g = g(n); for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1); return g;}
    static void rdg(List<List<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1);}
    static List<Set<Integer>> rsg(int n, int m) throws IOException {List<Set<Integer>> g = sg(n); for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1); return g;}
    static void rsg(List<Set<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1);}
    static List<Set<Integer>> rdsg(int n, int m) throws IOException {List<Set<Integer>> g = sg(n); for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1); return g;}
    static void rdsg(List<Set<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1);}
    // output
    static void pr(int i) {__out.print(i);}
    static void prln(int i) {__out.println(i);}
    static void pr(long l) {__out.print(l);}
    static void prln(long l) {__out.println(l);}
    static void pr(double d) {__out.print(d);}
    static void prln(double d) {__out.println(d);}
    static void pr(char c) {__out.print(c);}
    static void prln(char c) {__out.println(c);}
    static void pr(char[] s) {__out.print(new String(s));}
    static void prln(char[] s) {__out.println(new String(s));}
    static void pr(String s) {__out.print(s);}
    static void prln(String s) {__out.println(s);}
    static void pr(Object o) {__out.print(o);}
    static void prln(Object o) {__out.println(o);}
    static void prln() {__out.println();}
    static void pryes() {prln("yes");}
    static void pry() {prln("Yes");}
    static void prY() {prln("YES");}
    static void prno() {prln("no");}
    static void prn() {prln("No");}
    static void prN() {prln("NO");}
    static void pryesno(boolean b) {prln(b ? "yes" : "no");};
    static void pryn(boolean b) {prln(b ? "Yes" : "No");}
    static void prYN(boolean b) {prln(b ? "YES" : "NO");}
    static void prln(int... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(long... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(double... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static <T> void prln(Collection<T> c) {int n = c.size() - 1; Iterator<T> iter = c.iterator(); for (int i = 0; i < n; pr(iter.next()), pr(' '), ++i); if (n >= 0) prln(iter.next()); else prln();}
    static void h() {prln("hlfd"); flush();}
    static void flush() {__out.flush();}
    static void close() {__out.close();}}

import java.util.*;
import java.io.*;
import java.math.*;
public class Main{

	//static int p=1000000007;

	static long pr = 998244353;

	static BigInteger p =  new BigInteger(998244353+"");

	static void err() {
		System.out.println(-1);
	}

	public static void main (String args[])throws IOException{
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);

		int t = 1;
		//t = sc.nextInt();

		while(t-->0) {

			long n=sc.nextInt(), m=sc.nextInt(), l=sc.nextInt(), r=sc.nextInt(), k=r-l, even=k/2+1, odd=(k+1)/2;

			if((n*m)%2==1) {
				out.print(new BigInteger(k+1+"").modPow(new BigInteger(n*m+""), p));
			}else {

				BigInteger temp1 = new BigInteger(even+odd+"").modPow(new BigInteger(n*m+""), p);
				BigInteger temp2 = new BigInteger(even-odd+"").modPow(new BigInteger(n*m+""), p);

				out.println(((Long.parseLong(temp1.toString())+Long.parseLong(temp2.toString()))*(pr+1)/2)%pr);
			}

		}
		out.flush();
	}

	public static String reverseString(String str){
	    StringBuilder sb=new StringBuilder(str);
	    sb.reverse();
	    return sb.toString();
	}

	static boolean isPalindrome(String str)
    {
        int i = 0, j = str.length() - 1;

        while (i < j) {

            if (str.charAt(i) != str.charAt(j))
                return false;

            i++;
            j--;
        }
        return true;
    }

	static void print(int[] arr) {
		for(int i=0; i<arr.length; i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}

	public static int abs(int x) {return ((x > 0) ? x : -x);}
	public static long abs(long x) {return ((x > 0) ? x : -x);}

	public static int max(int a, int b) {return Math.max(a, b);}
	public static long max(long a, long b) {return Math.max(a, b);}

	public static int min(int a, int b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a, b);}

	 static int gcd(int a, int b)
	    {
	        if (a == 0)
	            return b;
	        return gcd(b % a, a);
	    }

    static int modInverse(int a, int m)
    {
        int g = gcd(a, m);
        if (g != 1)
            return -1;
        else
        	return power(a, m - 2, m);

    }

    // To compute x^y under modulo m
    static int power(int x, int y, int m)
    {
        if (y == 0)
            return 1;

        int p = power(x, y / 2, m) % m;
        p = (p * p) % m;

        if (y % 2 == 0)
            return p;
        else
            return (x * p) % m;
    }

    static int[] primeGenerator(int num) {
    	int length=0, arr[]=new int[num], a=num, factor=1;
    	if(num%2==0) {
    		while(num%2==0) {
    			num/=2;
    			factor*=2;
    		}
    		arr[length++]=factor;
    	}
    	for(int i=3; i*i<=a; i++) {
    		factor=1;
    		if(num%i==0) {
        		while(num%i==0) {
        			num/=i;
        			factor*=i;
        		}
        		arr[length++]=factor;
    		}
    	}
    	if(num>1)
    		arr[length++]=num;
    	return Arrays.copyOfRange(arr, 0, length);
    }

    static boolean isPrime(int n)
    {
        // Corner cases
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        // This is checked so that we can skip
        // middle five numbers in below loop
        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}
}

class Pair{
	int x;
	int y;
	Pair(int a, int b){
		x=a;
		y=b;
	}

	void print() {
		System.out.println(this.x+" "+this.y);
	}
}

import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.Flushable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.InputMismatchException;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	static class TaskAdapter implements Runnable {
		@Override
		public void run() {
			long startTime = System.currentTimeMillis();
			InputStream inputStream = System.in;
			OutputStream outputStream = System.out;
			FastReader in = new FastReader(inputStream);
			Output out = new Output(outputStream);
			EHeightAllTheSame solver = new EHeightAllTheSame();
			solver.solve(1, in, out);
			out.close();
			System.err.println(System.currentTimeMillis()-startTime+"ms");
		}

	}

	public static void main(String[] args) throws Exception {
		Thread thread = new Thread(null, new TaskAdapter(), "", 1<<28);
		thread.start();
		thread.join();
	}

	static class EHeightAllTheSame {
		private final int mod = 998244353;

		public EHeightAllTheSame() {
		}

		public void solve(int kase, InputReader in, Output pw) {
			long nn = in.nextInt(), nm = in.nextInt(), l = in.nextInt(), r = in.nextInt();
			long n = nn*nm;
			if((n&1)==1) {
				pw.println(Utilities.math.pow(r-l+1, n, mod));
			}else {
				long x = Utilities.math.pow(r-l+1, n, mod);
				if(((r-l+1)&1)==1) {
					x++;
				}
				pw.println((x*499122177L)%mod);
			}
		}

	}

	static interface InputReader {
		int nextInt();

	}

	static class Output implements Closeable, Flushable {
		public StringBuilder sb;
		public OutputStream os;
		public int BUFFER_SIZE;
		public boolean autoFlush;
		public String lineSeparator;

		public Output(OutputStream os) {
			this(os, 1<<16);
		}

		public Output(OutputStream os, int bs) {
			BUFFER_SIZE = bs;
			sb = new StringBuilder(BUFFER_SIZE);
			this.os = new BufferedOutputStream(os, 1<<17);
			autoFlush = false;
			lineSeparator = System.lineSeparator();
		}

		public void println(long l) {
			println(String.valueOf(l));
		}

		public void println(String s) {
			sb.append(s);
			println();
			if(autoFlush) {
				flush();
			}else if(sb.length()>BUFFER_SIZE >> 1) {
				flushToBuffer();
			}
		}

		public void println() {
			sb.append(lineSeparator);
		}

		private void flushToBuffer() {
			try {
				os.write(sb.toString().getBytes());
			}catch(IOException e) {
				e.printStackTrace();
			}
			sb = new StringBuilder(BUFFER_SIZE);
		}

		public void flush() {
			try {
				flushToBuffer();
				os.flush();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

		public void close() {
			flush();
			try {
				os.close();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

	}

	static class FastReader implements InputReader {
		final private int BUFFER_SIZE = 1<<16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer;
		private int bytesRead;

		public FastReader(InputStream is) {
			din = new DataInputStream(is);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public int nextInt() {
			int ret = 0;
			byte c = skipToDigit();
			boolean neg = (c=='-');
			if(neg) {
				c = read();
			}
			do {
				ret = ret*10+c-'0';
			} while((c = read())>='0'&&c<='9');
			if(neg) {
				return -ret;
			}
			return ret;
		}

		private boolean isDigit(byte b) {
			return b>='0'&&b<='9';
		}

		private byte skipToDigit() {
			byte ret;
			while(!isDigit(ret = read())&&ret!='-') ;
			return ret;
		}

		private void fillBuffer() {
			try {
				bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			}catch(IOException e) {
				e.printStackTrace();
				throw new InputMismatchException();
			}
			if(bytesRead==-1) {
				buffer[0] = -1;
			}
		}

		private byte read() {
			if(bytesRead==-1) {
				throw new InputMismatchException();
			}else if(bufferPointer==bytesRead) {
				fillBuffer();
			}
			return buffer[bufferPointer++];
		}

	}

	static class Utilities {
		public static class math {
			public static long pow(long base, long exp, long mod) {
				long ans = 1, cur = base;
				while(exp>0) {
					if((exp&1)>0) {
						ans = (ans*cur)%mod;
					}
					cur = (cur*cur)%mod;
					exp >>= 1;
				}
				return ans;
			}

		}

	}
}

import java.util.Scanner;

public class E {
	static int MOD = 998244353;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int L = sc.nextInt();
		int R = sc.nextInt();
		int pow = R-L+1;
		if(n%2==0 || m%2==0) {
			int a = 0;
			int b =0;
			if(R%2==0 && L%2==0) {
				a = (R-L)/2+1;
				b = (R-L)/2;
			}
			else if(R%2==1 && L%2==1) {
				a = (R-L)/2;
				b = (R-L)/2+1;
			}
			else {
				a = (R-L+1)/2;
				b =(R-L+1)/2;
			}
			int fir = (a+b);
			int sec = a-b;
			fir%=MOD;
			sec%=MOD;
			long exp = (long) n*m;
			exp%=(MOD-1);
			long ans = exp(fir,(int) exp);
			ans+=exp(sec,(int) exp);
			ans%=MOD;
			long mult  = exp(2,MOD-2);
			ans*=mult;
			ans%=MOD;
			System.out.println(ans);
		}
		else {
			long exp = (long) n*m;
			exp%=(MOD-1);
			long ans = exp(pow,(int) exp);
			System.out.println(ans);
		}
	}
	static long exp(int base,int power) {
		if(base==0) return 0;
		if(power==0) return 1;
		if(power==1) return (base+MOD)%MOD;
		long ans = exp(base,power/2);
		ans = (ans*ans+MOD)%MOD;
		if(power%2==1) ans = (ans*base+MOD)%MOD;
		return (ans+MOD)%MOD;
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
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;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EHeightAllTheSame solver = new EHeightAllTheSame();
        solver.solve(1, in, out);
        out.close();
    }

    static class EHeightAllTheSame {
        final static long mod = 998244353;

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            long n = in.scanInt();
            long m = in.scanInt();
            long l = in.scanInt();
            long r = in.scanInt();

            long total = CodeX.power((r - l + 1) % mod, n * m, mod);
            if ((n * m) % 2 == 1) {
                out.println(total);
            } else {

                long range = r - l + 1;

                if (range % 2 == 0) {
                    out.println((total * ((mod + 1) / 2)) % mod);
                } else {
                    out.println(((total + 1) * ((mod + 1) / 2)) % mod);
                }

            }

        /*
            0 1

               2*2*2*2

               00--> 00  1
               01--> 01  0
               02--> 00  1
               10--> 10  0
               11--> 11  1
               12--> 10  0
               20--> 00  1
               21--> 01  0
               22--> 00  1
         */
        /*
           - -
         */

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }

    static class CodeX {
        public static long power(long x, long y, long p) {
            long res = 1;
            x = x % p;
            while (y > 0) {

                if ((y & 1) != 0)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
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;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EHeightAllTheSame solver = new EHeightAllTheSame();
        solver.solve(1, in, out);
        out.close();
    }

    static class EHeightAllTheSame {
        final static long mod = 998244353;

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            long n = in.scanInt();
            long m = in.scanInt();
            long l = in.scanInt();
            long r = in.scanInt();

            long total = CodeX.power((r - l + 1) % mod, n * m, mod);
            if ((n * m) % 2 == 1) {
                out.println(total);
            } else {

                long range = r - l + 1;

                if (range % 2 == 0) {
                    out.println((total * CodeX.modinv(2, mod)) % mod);
                } else {
                    out.println(((total + 1) * CodeX.modinv(2, mod)) % mod);
                }

            }

        /*
            0 1

               2*2*2*2

               00--> 00  1
               01--> 01  0
               02--> 00  1
               10--> 10  0
               11--> 11  1
               12--> 10  0
               20--> 00  1
               21--> 01  0
               22--> 00  1
         */
        /*
           - -
         */

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }

    static class CodeX {
        public static long power(long x, long y, long p) {
            long res = 1;
            x = x % p;
            while (y > 0) {

                if ((y & 1) != 0)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }

        public static long modinv(long k, long mod) {
            return power(k, mod - 2, mod);
        }

    }
}

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

public class E630 {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        long n = sc.nextLong(); long m = sc.nextLong(); long l = sc.nextLong(); long r = sc.nextLong();
        long need = (n * m) % 2;
        long a = r - l + 1;
        if (a % 2 == 0) {
            if (need % 2 == 1) {
                long ret = (pow(a, n * m)) % mod;
                out.println(ret);
            } else {
                long ret = pow(a, n * m);
                ret = (ret * inv(2)) % mod;
                out.println(ret);
            }
        } else {
            if (need == 0) {
                long ret = (pow(a, n * m) + 1) % mod;
                ret = (ret * inv(2)) % mod;
                out.println(ret);
            } else {
                long ret = (pow(a, n * m)) % mod;
                out.println(ret);
            }
        }
        out.close();
    }

    static long[] fac;
    static long mod = 998244353;

    static void initFac(long n) {
        fac[0] = 1;
        for (int i = 1; i <= n; i++) {
            fac[i] = (fac[i - 1]  * i) % mod;
        }
    }

    static long nck(int n, int k) {
        if (n < k)
            return 0;
        long den = inv((int) (fac[k] * fac[n - k] % mod));
        return fac[n] * den % mod;
    }

    static long pow(long b, long e) {
        long ans = 1;
        while (e > 0) {
            if (e % 2 == 1)
                ans = ans * b % mod;
            e >>= 1;
            b = b * b % mod;
        }
        return ans;
    }

    static long inv(long x) {
        return pow(x, mod - 2);
    }

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

}

import java.util.Scanner;
import java.math.BigInteger;
import java.util.Vector;

public class Main {
	public static void main(String[] args) {
		BigInteger MOD = BigInteger.valueOf(998244353);

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long L = sc.nextLong();
		long R = sc.nextLong();

		long k = R - L + 1;

		if (n * m % 2 == 1) {
			BigInteger exp = BigInteger.valueOf(n * m);
			BigInteger base = BigInteger.valueOf(k);
			System.out.println(base.modPow(exp, MOD));
		} else {
			long e, o;
			BigInteger E, O, exp;
			e = R / 2 - (L - 1) / 2;
			o = k - e;
			E = BigInteger.valueOf(e);
			O = BigInteger.valueOf(o);
			exp = BigInteger.valueOf(n * m);
			BigInteger a = E.add(O).modPow(exp, MOD);
			BigInteger b = E.subtract(O).modPow(exp, MOD);
			System.out.println(a.add(b).multiply(MOD.add(BigInteger.ONE)).divide(BigInteger.valueOf(2)).mod(MOD));

		}

	}
}

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

public class ProbE {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        static int MOD = 998244353;
        public long pow(long x, long y){
            if (y == 0){
                return 1;
            }
            else{
                long au = pow(x, y / 2);
                au = (au * au) % MOD;
                if (y % 2 == 0){
                    return au;
                }
                else{
                    return (au * x) % MOD;
                }
            }
        }
        public void solve(InputReader in, PrintWriter out) {
            long n = in.nextInt();
            long m = in.nextInt();
            long l = in.nextInt();
            long r = in.nextInt();
            long result= -1;
            if (m % 2 == 1 && n % 2 == 1){
                result = pow(r - l + 1, m * n);
            }
            else{
                long s = r - l + 1;
                long d = (r - l + 1) % 2;
                result = (pow(s, m * n) + pow(d, m * n)) % MOD;
                result = (result * pow(2, MOD - 2)) % MOD;
            }
            out.println(result);
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

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

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}

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

public class E {

    public static void main(String args[]) throws IOException {
        FastScanner in = new FastScanner(System.in);
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        int t = 1;
        while (t-- > 0) {
            solve(in, out);
        }
        out.flush();
    }

    public static void solve(FastScanner in, BufferedWriter out) throws IOException {
        long n = in.nextInt();
        long m = in.nextInt();
        long L = in.nextInt();
        long R = in.nextInt();
        long k = R - L + 1;
        long ans = 1;
        long mod = 998244353;
        if ((n * m) % 2 != 0) {
            ans = power(k, n * m, mod);
        } else {
            long E = (k + 1) / 2;
            long O = (k) / 2;
            ans = power((E + O), n * m, mod);
            ans = (ans + (E - O)) % mod;
            ans = (ans * (mod + 1) / 2) % mod; // modular_inverse of 2 is (mod+1) / 2;
            ans %= mod;
        }
        out.write(ans + "\n");
    }

    private static long power(long x, long y, long mod) {
        x = x % mod;
        long res = 1;
        while (y > 0) {
            if ((y & 1) == 1) {
                res = (res * x) % mod;
            }
            y = (y >> 1);
            x = (x * x) % mod;
        }
        return res;
    }

    private static class FastScanner {
        private BufferedReader reader;

        private StringTokenizer tokenizer;

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }

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

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

import java.util.*;

public class HeightOfAllSame {
    static int modulo = 998244353;

    static long pwmd(long a, long n) {
        if (n == 0) {
            return 1;
        }
        long pt = pwmd(a, n / 2);
        pt *= pt;
        pt %= modulo;
        if (n % 2 != 0) {
            pt *= a;
            pt %= modulo;
        }
        return pt;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int r = sc.nextInt();

        long t = (long) r - l + 1;
        long e = r / 2 - (l - 1) / 2;
        long o = t - e;

        long x = (long) n * m;

        if (x % 2 != 0) {
            System.out.println(pwmd(t, x));
        } else {
            long sub = pwmd(e + o, x) - pwmd(Math.abs(e - o), x);
            sub += modulo;
            sub %= modulo;
            sub = (sub * pwmd(2, modulo - 2)) % modulo;
            long total = pwmd(t, x);
            long ans = (total - sub + modulo) % modulo;
            System.out.println(ans);
        }

    }
}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class C1332E {

    static final long MODULO = 998244353;

    public static void main(String[] args) {
        var scanner = new BufferedScanner();
        var writer = new PrintWriter(new BufferedOutputStream(System.out));

        var n = scanner.nextLong();
        var m = scanner.nextLong();
        var L = scanner.nextLong();
        var R = scanner.nextLong();
        long ans;
        if (n * m % 2 == 1) {
            ans = power(R - L + 1, n * m);
        } else {
            if ((R - L + 1) % 2 == 0) {
                ans = mul((R - L + 1) / 2, power(R - L + 1, n * m - 1));
            } else {
                ans = div(add(1, power(R - L + 1, m * n)), 2);
            }
        }
        writer.println(ans);

        scanner.close();
        writer.flush();
        writer.close();
    }

    private static long div(long a, long b) {
        var inv = inverse(b, MODULO);
        return (a * inv) % MODULO;
    }

    private static long add(long a, long b) {
        return (a + b) % MODULO;
    }

    private static long power(long base, long exp) {
        if (exp == 0) {
            return 1;
        } else if (exp == 1) {
            return base;
        } else {
            var half = power(base, exp / 2);
            if (exp % 2 == 0) {
                return mul(half, half);
            } else {
                return mul(base, half, half);
            }
        }
    }

    private static long mul(long... a) {
        var ans = 1L;
        for (long x : a) {
            ans = ans * x % MODULO;
        }
        return ans;
    }

    public static class BufferedScanner {
        BufferedReader br;
        StringTokenizer st;

        public BufferedScanner(Reader reader) {
            br = new BufferedReader(reader);
        }

        public BufferedScanner() {
            this(new InputStreamReader(System.in));
        }

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

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

    static long gcd(long a, long b) {
        if (a < b) {
            return gcd(b, a);
        }
        while (b > 0) {
            long tmp = b;
            b = a % b;
            a = tmp;
        }
        return a;
    }

    static long inverse(long a, long m) {
        long[] ans = extgcd(a, m);
        return ans[0] == 1 ? (ans[1] + m) % m : -1;
    }

    private static long[] extgcd(long a, long m) {
        if (m == 0) {
            return new long[]{a, 1, 0};
        } else {
            long[] ans = extgcd(m, a % m);
            long tmp = ans[1];
            ans[1] = ans[2];
            ans[2] = tmp;
            ans[2] -= ans[1] * (a / m);
            return ans;
        }
    }

    private static List<Integer> primes(double upperBound) {
        var limit = (int) Math.sqrt(upperBound);
        var isComposite = new boolean[limit + 1];
        var primes = new ArrayList<Integer>();
        for (int i = 2; i <= limit; i++) {
            if (isComposite[i]) {
                continue;
            }
            primes.add(i);
            int j = i + i;
            while (j <= limit) {
                isComposite[j] = true;
                j += i;
            }
        }
        return primes;
    }

}

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

/*
Прокрастинирую
*/

public class Main {

    static FastReader in;
    static PrintWriter out;
    static Random rand = new Random();
    static final int INF = (int) (1e9 + 10), MOD = (int) (998244353), LOGN = 20;
    static final long IINF = (long) (2e18 + 10);

    static long pow(long a, long b) {
        long res = 1;
        while (b != 0) {
            if ((b & 1) != 0) {
                res = (res * a) % MOD;
            }
            a = (a * a) % MOD;
            b >>= 1;
        }
        return res;
    }

    static long even, odd;
    static HashMap<Long, Long> dp0;
    static HashMap<Long, Long> dp1;
    static long go(long n, int x) {
        if (x == 0) {
            if (dp0.containsKey(n)) {
                return dp0.get(n);
            }
            if (n == 1) {
                long res = even;
                dp0.put(n, res);
                return res;
            } else if (n == 2) {
                long res = (even * even + odd * odd) % MOD;
                dp0.put(n, res);
                return res;
            }
            long a1 = go(n / 2, 0);
            long a2 = go(n - n / 2, 0);
            long b1 = go(n / 2, 1);
            long b2 = go(n - n / 2, 1);
            long res = (a1 * a2 + b1 * b2) % MOD;
            dp0.put(n, res);
            return res;
        } else {
            if (dp1.containsKey(n)) {
                return dp1.get(n);
            }
            if (n == 1) {
                long res = odd;
                dp1.put(n, res);
                return res;
            } else if (n == 2) {
                long res = (even * odd + odd * even) % MOD;
                dp1.put(n, res);
                return res;
            }
            long a1 = go(n / 2, 0);
            long a2 = go(n - n / 2, 1);
            long b1 = go(n / 2, 1);
            long b2 = go(n - n / 2, 0);
            long res = (a1 * a2 + b1 * b2) % MOD;
            dp1.put(n, res);
            return res;
        }
    }

    static void solve() {
        long n = in.nextInt();
        long m = in.nextInt();
        long l = in.nextInt();
        long r = in.nextInt();
        long sz = n * m;

        if (sz % 2 == 0) {
            even = (r - l + 1) / 2;
            if ((r - l) % 2 == 0 && l % 2 == 0) even++;
            odd = r - l + 1 - even;

            dp0 = new HashMap<>();
            dp1 = new HashMap<>();
            out.println(go(sz, 0));
        } else {
            long ans = pow(r - l + 1, sz);
            out.println(ans);
        }
    }

    public static void main(String[] args) throws FileNotFoundException {
        in = new FastReader(System.in);
//        in = new FastReader(new FileInputStream("sometext.txt"));
        out = new PrintWriter(System.out);
//        out = new PrintWriter(new FileOutputStream("sometext.txt"));

        int tests = 1;
//        tests = in.nextInt();

        while (tests-- > 0) {
            solve();
        }

//        out.flush();
        out.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

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

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

        Double nextDouble() {
            return Double.parseDouble(next());
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(nextLine());
            }
            return st.nextToken();
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }
}

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

/*
Прокрастинирую
*/

public class Main {

    static FastReader in;
    static PrintWriter out;
    static Random rand = new Random();
    static final int INF = (int) (1e9 + 10), MOD = (int) (998244353), LOGN = 20;
    static final long IINF = (long) (2e18 + 10);

    static long pow(long a, long b) {
        long res = 1;
        while (b != 0) {
            if ((b & 1) != 0) {
                res = (res * a) % MOD;
            }
            a = (a * a) % MOD;
            b >>= 1;
        }
        return res;
    }

    static void solve() {
        long n = in.nextInt();
        long m = in.nextInt();
        long l = in.nextInt();
        long r = in.nextInt();

        long sz = n * m;

        if (sz % 2 == 1) {
            out.println(pow(r - l + 1, sz));
        } else {
            long e = (r - l + 1) / 2;
            if (l % 2 == 0 && r % 2 == 0) e++;
            long o = r - l + 1 - e;
            out.println((pow(e + o, sz) + pow(e - o, sz)) * pow(2, MOD - 2) % MOD);
        }
    }

    public static void main(String[] args) throws FileNotFoundException {
        in = new FastReader(System.in);
//        in = new FastReader(new FileInputStream("sometext.txt"));
        out = new PrintWriter(System.out);
//        out = new PrintWriter(new FileOutputStream("sometext.txt"));

        int tests = 1;
//        tests = in.nextInt();

        while (tests-- > 0) {
            solve();
        }

//        out.flush();
        out.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

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

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

        Double nextDouble() {
            return Double.parseDouble(next());
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(nextLine());
            }
            return st.nextToken();
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }
}

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

public class Solution{

	static long mod = 998244353L;

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

		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		long n = fs.nextLong(), m = fs.nextLong(), l = fs.nextLong(), r = fs.nextLong();

		if((n*m&1)==1) {
			out.println(exp(r-l+1,n*m));
			out.close();
			return;
		}

		long E = r/2 - (l-1)/2;
		long O = r-l+1 - E;

		long ans = (exp(E+O,n*m) + exp(E-O,n*m))%mod;
		ans = (ans*exp(2,mod-2))%mod;

		out.println(ans);

		out.close();
	}

	//BINARY EXPONENTIATION
	static long exp(long a, long n) {
		long res = 1L;
		while(n>0) {
			if((n&1)==1) {
				res = (res*a)%mod;
			}
			a = (a*a)%mod;
			n = n>>1;
		}
		return res;
	}

	static class FastScanner{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

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

}

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
 import java.util.*;
 public class realfast implements Runnable
  {
    private static final int INF = (int) 1e9;
    long in= (long)Math.pow(10,9)+7;
    long fac[]= new long[3000];
    public  void solve() throws IOException
    {
       long n = readLong();
       long m = readLong();
       long l = readLong();
       long r = readLong();
       long rem = 998244353;
       long len = (r-l+1);

       //out.println(len);
       long val = pow(len,n*m,rem);
        //out.println(val);
        if((n%2!=0)&&(m%2!=0))
        {
            out.println(val);
        }
        else
        {
            if(len%2==1)
            val = (val+1)%rem;
           // out.println(val);
            val = (val*pow(2,rem-2,rem))%rem;
            out.println(val);
        }

    }

    public long pow(long n , long p,long m)
    {
         if(p==0)
            return 1;
        long val = pow(n,p/2,m);;
        val= (val*val)%m;
        if(p%2==0)
            return val;
        else
            return (val*n)%m;
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public static void main(String[] args) {
        new Thread(null, new realfast(), "", 128 * (1L << 20)).start();
    }

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    private PrintWriter out;

    @Override
    public void run() {
        try {
            if (ONLINE_JUDGE || !new File("input.txt").exists()) {
                reader = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                reader = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            }
            solve();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // nothing
            }
            out.close();
        }
    }

    private String readString() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    @SuppressWarnings("unused")
    private int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    @SuppressWarnings("unused")
    private long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    @SuppressWarnings("unused")
    private double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }
}
class edge implements Comparable<edge>{
    int u ;
    int v ;
    int val;
    edge(int u1, int v1 , int val1)
    {
       this.u=u1;
       this.v=v1;
       this.val=val1;
    }
    public int compareTo(edge e)
    {
        return this.val-e.val;
    }
}

import java.util.Scanner;

public class ProblemE {

	public static long M = 998244353;

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner s = new Scanner(System.in);
		long m = s.nextLong();
		long n = s.nextLong();

		long l = s.nextLong();
		long r = s.nextLong();

		long T = m * n;
		long num = r - l + 1;

		long a = exp(num, T);
		//System.out.println(a);
		if(T%2 == 1) {
			System.out.println(a);
		}

		else {
			if(num % 2 == 0)
				System.out.println((a * exp(2, M-2))%M);
			else
				System.out.println(((a + 1)%M * exp(2, M-2))%M);

		}

	}

	public static long exp(long a, long b) {
		long m = M;
		if(b == 0)
			return 1;
		else if(b == 1)
			return a;
		else if(a == 1)
			return 1;
		else if(b%2 == 0)
			return exp((a*a)%m, b/2);
		else
			return (exp((a*a)%m, b/2) * a)%m;
	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            EHeightAllTheSame solver = new EHeightAllTheSame();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class EHeightAllTheSame {
        Modular mod = new Modular(998244353);
        Debug debug = new Debug(true);
        Power power = new Power(mod);

        public int odd(int n) {
            return (n + 1) / 2;
        }

        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            int m = in.readInt();
            int l = in.readInt();
            int r = in.readInt();
            int odd = odd(r) - odd(l - 1);
            int even = (r - l + 1) - odd;
            debug.debug("odd", odd);
            debug.debug("even", even);

            if ((long) n * m % 2 == 1) {
                out.println(power.pow(r - l + 1, ((long) n * m)));
                return;
            }

            ModMatrix matrix = new ModMatrix(2, 2);
            matrix.set(0, 0, even);
            matrix.set(0, 1, odd);
            matrix.set(1, 0, odd);
            matrix.set(1, 1, even);
            matrix = ModMatrix.pow(matrix, (long) n * m, mod);
            ModMatrix vector = new ModMatrix(2, 1);
            vector.set(0, 0, 1);

            ModMatrix ans = ModMatrix.mul(matrix, vector, mod);
            out.println(ans.get(0, 0));
        }

    }

    static class Power {
        final Modular modular;

        public Power(Modular modular) {
            this.modular = modular;
        }

        public int pow(int x, long n) {
            if (n == 0) {
                return modular.valueOf(1);
            }
            long r = pow(x, n >> 1);
            r = modular.valueOf(r * r);
            if ((n & 1) == 1) {
                r = modular.valueOf(r * x);
            }
            return (int) r;
        }

    }

    static class Debug {
        private boolean offline;
        private PrintStream out = System.err;

        public Debug(boolean enable) {
            offline = enable && System.getSecurityManager() == null;
        }

        public Debug debug(String name, int x) {
            if (offline) {
                debug(name, "" + x);
            }
            return this;
        }

        public Debug debug(String name, String x) {
            if (offline) {
                out.printf("%s=%s", name, x);
                out.println();
            }
            return this;
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 20];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

    }

    static class Modular {
        int m;

        public int getMod() {
            return m;
        }

        public Modular(int m) {
            this.m = m;
        }

        public Modular(long m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public Modular(double m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public int valueOf(int x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return x;
        }

        public int valueOf(long x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return (int) x;
        }

        public int mul(int x, int y) {
            return valueOf((long) x * y);
        }

        public int plus(int x, int y) {
            return valueOf(x + y);
        }

        public String toString() {
            return "mod " + m;
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }

    static class ModMatrix {
        int[][] mat;
        int n;
        int m;

        public ModMatrix(ModMatrix model) {
            n = model.n;
            m = model.m;
            mat = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    mat[i][j] = model.mat[i][j];
                }
            }
        }

        public ModMatrix(int n, int m) {
            this.n = n;
            this.m = m;
            mat = new int[n][m];
        }

        public ModMatrix(int[][] mat) {
            if (mat.length == 0 || mat[0].length == 0) {
                throw new IllegalArgumentException();
            }
            this.n = mat.length;
            this.m = mat[0].length;
            this.mat = mat;
        }

        public void fill(int v) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    mat[i][j] = v;
                }
            }
        }

        public void asStandard(Modular mod) {
            fill(0);
            if (mod.getMod() == 1) {
                return;
            }
            for (int i = 0; i < n && i < m; i++) {
                mat[i][i] = 1;
            }
        }

        public void set(int i, int j, int val) {
            mat[i][j] = val;
        }

        public int get(int i, int j) {
            return mat[i][j];
        }

        public static ModMatrix mul(ModMatrix a, ModMatrix b, Modular modular) {
            ModMatrix c = new ModMatrix(a.n, b.m);
            for (int i = 0; i < c.n; i++) {
                for (int j = 0; j < c.m; j++) {
                    for (int k = 0; k < a.m; k++) {
                        c.mat[i][j] = modular.plus(c.mat[i][j], modular.mul(a.mat[i][k], b.mat[k][j]));
                    }
                }
            }
            return c;
        }

        public static ModMatrix pow(ModMatrix x, long n, Modular modular) {
            if (n == 0) {
                ModMatrix r = new ModMatrix(x.n, x.m);
                r.asStandard(modular);
                return r;
            }
            ModMatrix r = pow(x, n >> 1, modular);
            r = ModMatrix.mul(r, r, modular);
            if (n % 2 == 1) {
                r = ModMatrix.mul(r, x, modular);
            }
            return r;
        }

        public String toString() {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    builder.append(mat[i][j]).append(' ');
                }
                builder.append('\n');
            }
            return builder.toString();
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class EHeightAllTheSame {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            long n = s.nextLong(), m = s.nextLong(), k = n * m;
            long l = s.nextLong(), r = s.nextLong(), len = r - l + 1;
            long mod = 998244353;

            if (k % 2 == 1) {
                out.println(EHeightAllTheSame.Maths.power(len, n * m, mod));
                return;
            }

            long ans = (EHeightAllTheSame.Maths.power(len, k, mod) + EHeightAllTheSame.Maths.power(len % 2, k, mod)) * EHeightAllTheSame.Maths.power(2, mod - 2, mod) % mod;
            out.println(ans);
        }

        private static class Maths {
            static long power(long x, long y, long p) {
                long res = 1;
                x = x % p;

                while (y > 0) {
                    if ((y & 1) == 1)
                        res = (res * x) % p;
                    y = y >> 1;
                    x = (x * x) % p;
                }
                return res;
            }

        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

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

public class heightsame
{
	static long N, M, L, R;
	static BigInteger mod = BigInteger.valueOf(998244353);
	public static void main(String[] args) throws IOException
	{
		Scanner s = new Scanner(System.in);
		N = s.nextLong();
		M = s.nextLong();
		L = s.nextLong();
		R = s.nextLong();
		BigInteger diff = BigInteger.valueOf(R-L+1);
		BigInteger prod = BigInteger.valueOf(N*M);
		BigInteger ans = diff.modPow(prod, mod.multiply(BigInteger.valueOf(2)));
		if (prod.mod(BigInteger.valueOf(2)).equals(BigInteger.ZERO))
		{
			ans = ((ans.add(BigInteger.ONE)).divide(BigInteger.valueOf(2)));
		}
		System.out.println(ans.mod(mod));
		s.close();
	}
}

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

public class Main {
 	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);

 		long n =fr.nextLong()*fr.nextLong() ,l =fr.nextLong() ,r =fr.nextLong() ,md =998244353l ,i ,j ,ans ;
 		if ((r-l+1l)%2l == 0l)	j =0l ;	else 	j =1l ;
 		l %= md ;	r %= md ;	i =(r-l + md)%md ;	i =(i + 1l)%md ;

 		i =pow (i , n , md) ;	j =pow (j , n , md) ;
 		if (n%2l == 0l) {
 			i =(i + j)%md ;	j =pow (2l , md-2l , md) ;	i =(i*j)%md ;
 		}
		op.println(i) ;	op.flush();	op.close();
	}
	static long pow (long b , long e , long md) {
		if (e==0l)	return 1l;
		if (e==1l)	return b;
		long dm =pow(b , e/2l , md) ;	dm =(dm * dm)%md ;
		if ((e&1l) == 1l)	dm =(dm * b)%md ;
		return dm ;
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

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

			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

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

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

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

public class E1332 {

	static int mod = 998244353;

	static long[][] matMul(long[][] A, long[][] B, int p, int q, int r) // C(p x r) = A(p x q) x (q x r) -- O(p x q x r)
	{
		long[][] C = new long[p][r];
		for (int i = 0; i < p; ++i)
			for (int j = 0; j < r; ++j)
				for (int k = 0; k < q; ++k) {
					C[i][j] += (A[i][k] * B[k][j]) % mod;
					C[i][j] %= mod;
				}
		return C;
	}

	/*
	 * 4. Square Matrix Exponentiation
	 */
	static long[][] matPow(long[][] base, long p) {
		int n = base.length;
		long[][] ans = new long[n][n];
		for (int i = 0; i < n; i++)
			ans[i][i] = 1;
		while (p != 0) {
			if ((p & 1) == 1)
				ans = matMul(ans, base, n, n, n);
			base = matMul(base, base, n, n, n);
			p >>= 1;
		}

		return ans;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long n = sc.nextInt();
		long m = sc.nextInt();
		int l = sc.nextInt();
		int r = sc.nextInt();
		int e = (r) / 2 - (l - 1) / 2;
		int o = (r - l + 1) - e;
		long[][] mat = { { e, o }, { o, e } };
		long[][] ans = matPow(mat, n * m);
		ans = matMul(new long[][] { { 1l, 0l } }, ans, 1, 2, 2);

		pw.println((ans[0][0] + ans[0][1] * (n * m % 2)) % mod);
		pw.close();

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextInt();
			return arr;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}

/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class HeightAllTheSame {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        long N = sc.nextLong();
        long M = sc.nextLong();
        long L = sc.nextLong();
        long R = sc.nextLong();

        long E = (R - L + 1) / 2 + (R % 2 == 0 && L % 2 == 0 ? 1 : 0);
        long O = (R - L + 1) - E;
        // Key thing to observe: if we have any valid starting position
        // with an EVEN number of ODD-heighted blocks, then it'll be possible.
        /** actually, it's more subtle than that. You need to just have everything
         * be the SAME at the end. This means an even number of AT LEAST ONE of them
         * will allow for a solution. All that matters is that everything is
         * neutralized into the other type, so if one of them has even count, then
         * we turn it all into the other. However, if NM is even, then the odd odd case fails
         */
        // Basically, we notice that we can flip any pair of OE blocks, and
        // then in this way we can move any odd blocks together, then flip those
        // OO into an EE pair. So, the starting position just needs an even number
        // of odd blocks for this invariant of the same parity of number of ODD
        // blocks to be satisfied

        // This can be visualized as the generating function (E+O)^(NM)
        // since this illustrates the distribution of ways to make each of the NM cells
        // However, we only want the O^(2k) terms for all k. So, we use
        // the trick of adding it to (E-O)^(NM), since all odd terms will cancel
        // Then, we divide by 2, and we have the total answer!
        long ans;
        if (N * M % 2 == 1) {
            ans = fastExpo(E + O, N * M);
        }
        else {
            ans = (fastExpo(E + O, N * M) + fastExpo(E - O, N * M)) % mod;
            ans = (ans * modInv(2)) % mod; // divide by 2 now
        }
        out.println(ans);
        out.close();
    }

    static long mod = 998244353;

    static long modInv(long x) {
        return fastExpo(x, mod - 2);
    }

    static long fastExpo(long x, long k) {
        if (k == 0) {
            return 1;
        }
        else if (k == 1) {
            return x;
        }
        else {
            long root = fastExpo(x, k / 2);
            long ans = (root * root) % mod;
            if (k % 2 == 1) {
                ans = (ans * x) % mod;
            }
            return ans;
        }
    }

    static class FastScanner {
        public int BS = 1<<16;
        public char NC = (char)0;
        byte[] buf = new byte[BS];
        int bId = 0, size = 0;
        char c = NC;
        double cnt = 1;
        BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            }
            catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar(){
            while(bId==size) {
                try {
                    size = in.read(buf);
                }catch(Exception e) {
                    return NC;
                }
                if(size==-1)return NC;
                bId=0;
            }
            return (char)buf[bId++];
        }

        public int nextInt() {
            return (int)nextLong();
        }

        public int[] nextInts(int N, int dx) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong() + dx;
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt=1;
            boolean neg = false;
            if(c==NC)c=getChar();
            for(;(c<'0' || c>'9'); c = getChar()) {
                if(c=='-')neg=true;
            }
            long res = 0;
            for(; c>='0' && c <='9'; c=getChar()) {
                res = (res<<3)+(res<<1)+c-'0';
                cnt*=10;
            }
            return neg?-res:res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c!='.' ? cur:cur+nextLong()/cnt;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c>32) {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c!='\n') {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if(c>32)return true;
            while(true) {
                c=getChar();
                if(c==NC)return false;
                else if(c>32)return true;
            }
        }
    }
}

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import java.util.*;

public class template {

	InputStream is;
	PrintWriter out;
	String INPUT = "";
	int mod = 998244353;

	void solve() {
		int n = ni();
		int m = ni();
		int l = ni();
		int r = ni();
		int t = r-l+1;
		int e = r/2-(l-1)/2;
		int o = t-e;

		if((n*1l*m) % 2 == 0) {
			long total = power(r-l+1l,n*1l*m,mod*1l);
			long t1 = power(e+o,n*1l*m,mod) - power(e-o , n*1l*m,mod)+mod;
			t1 = t1%mod;
			t1 = t1*modInverse(2, mod);
			t1 = t1%mod;
			total -= t1;
			total += mod;
			total = total%mod;
			out.println(total);
		}
		else {
			out.println(power(r-l+1l,n*1l*m,mod*1l));
		}

	}
	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
		//tr(System.currentTimeMillis()-s+"ms");
	}

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

	private void sort(int[] arr, int start, int end){
        if(start >= end) return;
        int mid = start + (end - start) / 2;
        sort(arr, start, mid);
        sort(arr, mid +1, end);
        merge(arr, start, mid, end);
    }
	private void merge(int[] arr, int start, int mid, int end){
        int i = start, j = mid + 1;
        int[] help = new int[end - start + 1];
        int c = 0;
        while(i <= mid && j <= end){
            help[c++] = arr[j] < arr[i] ? arr[j++] : arr[i++];
        }
        while(i <= mid){
            help[c++] = arr[i++];
        }
        while(j <= end){
            help[c++] = arr[j++];
        }
        for(int k = 0; k < help.length; k++){
            arr[start + k] = help[k];
        }
    }
	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 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 char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

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

	private int[][] na(int n , int m)
	{
		int[][] a = new int[n][m];
		for(int i = 0;i < n;i++)
			for(int j = 0 ; j<m ; j++) a[i][j] = ni();
		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 * 10 + (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 display2D(int a[][]) {
		for(int i[] : a) {
			for(int j : i) {
				out.print(j+" ");
			}
			out.println();
		}
	}

	int[][] creategraph(int n , int m) {
		int g[][] = new int[n+1][];

		int from[] = new int[m];
		int to[] = new int[m];
		int ct[] = new int[n+1];

		for(int i = 0 ; i<m; i++) {
			from[i] = ni();
			to[i] = ni();
			ct[from[i]]++;
			ct[to[i]]++;
		}

		int parent[] = new int[n+1];

		for(int i = 0 ; i<n+1 ; i++) g[i] = new int[ct[i]];

		for(int i = 0 ; i<m ; i++) {
			g[from[i]][--ct[from[i]]] = to[i];
			g[to[i]][--ct[to[i]]] = from[i];
		}

		return g;
	}

	static long __gcd(long a, long b)
	{

		if(b == 0)
		{
			return a;
		}
		else
		{
			return __gcd(b, a % b);
		}
	}

	// To compute x^y under modulo m
	static long power(long x, long y, long p)
	{

		// Initialize result
		long res = 1;

		// Update x if it is more than or
		// equal to p
		x = x % p;

		while (y > 0)
		{

			// If y is odd, multiply x
			// with result
			if (y % 2 == 1)
				res = (res * x) % p;

			// y must be even now
			y = y >> 1; // y = y/2
		x = (x * x) % p;
		}

		return res;
	}

	// Function to find modular
	// inverse of a under modulo m
	// Assumption: m is prime
	static long modInverse(long a, int m)
	{
		if (__gcd(a, m) != 1) {
			//System.out.print("Inverse doesn't exist");
			return -1;
		}

		else {

			// If a and m are relatively prime, then
			// modulo inverse is a^(m-2) mode m
			//			System.out.println("Modular multiplicative inverse is "
			//											+power(a, m - 2, m));
			return power(a, m - 2, m);
		}
	}

	static long nCrModPFermat(int n, int r,
			int p , long fac[])
	{

		// Base case
		if (r == 0)
			return 1;

		// Fill factorial array so that we
		// can find all factorial of r, n
		// and n-r
		long t = (fac[n]* modInverse(fac[r], p))%p;

		return ( (t* modInverse(fac[n-r], p))% p);
	}

	private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}

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

public class E implements Runnable {
	boolean judge = false;
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		long n = scn.nextLong(), m = scn.nextLong(), k = n * m;
		long l = scn.nextLong(), r = scn.nextLong(), len = r - l + 1;
		long mod = 998244353;

		if (k % 2 == 1) {
			out.println(pow(len, k, mod));
			return;
		}
		long ans = (pow(len, k, mod) + len % 2) * ((mod + 1) / 2) % mod;
		out.println(ans);
	}

	long pow(long a, long x, long m) {
		long rv = 1;
		while (x != 0) {
			if ((x & 1) == 1) {
				rv = (rv * a) % m;
			}
			a = (a * a) % m;
			x = x >> 1;
		}
		return rv;
	}

	public void run() {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null || judge;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) {
		new Thread(null, new E(), "Main", 1 << 28).start();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

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

		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++];
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

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

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

		char[] next(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);
		}

		int nextInt() {
			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 * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			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();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

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

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		int[][] next2DInt(int n, int m) {
			int[][] arr = new int[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextIntArray(m);
			}
			return arr;
		}

		long[][] next2DLong(int n, int m) {
			long[][] arr = new long[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLongArray(m);
			}
			return arr;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				int c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		long[] shuffle(long[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				long c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		int[] uniq(int[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			int[] rv = new int[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		long[] uniq(long[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			long[] rv = new long[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		int[] reverse(int[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		long[] reverse(long[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		int[] compress(int[] arr) {
			int n = arr.length;
			int[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}

		long[] compress(long[] arr) {
			int n = arr.length;
			long[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}
	}
}

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

public class E implements Runnable {
	boolean judge = false;
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		long n = scn.nextLong(), m = scn.nextLong();
		long l = scn.nextLong(), r = scn.nextLong(), mod = 998244353;

		if((n * m) % 2 == 1) {
			out.println(pow(r - l + 1, n * m, mod));
			return;
		}

		long x = (r - l + 1) / 2;
		long k = n * m;
		long two = pow(2, k - 1, mod);

		long ans = (pow(x, k, mod) * two) % mod;
		if((r - l + 1) % 2 != 0) {
			long y = r - l + 1 - x;
			ans = (pow(y + x, k, mod) + pow(y - x, k, mod)) % mod;
			ans = (ans * pow(2, mod - 2, mod)) % mod;
		}
		out.println(ans);
	}

	long func(long k, long z, long mod) {
		if(z == 0) {
			return 0;
		}
		long x = z / 2, y = z - x;
		if(x == 0 || y == 0) {
			return 1;
		}

		long ans = 0;
		for(long a = 0; a <= k; a += 2) {
			long b = k - a;

			long rv = pow(x, a, mod) * pow(y, b, mod) % mod;
			ans = (ans + rv) % mod;
		}

		return ans;
	}

	long pow(long a, long x, long m) {
		long rv = 1;
		while (x != 0) {
			if ((x & 1) == 1) {
				rv = (rv * a) % m;
			}
			a = (a * a) % m;
			x = x >> 1;
		}
		return rv;
	}

	public void run() {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null || judge;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) {
		new Thread(null, new E(), "Main", 1 << 28).start();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

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

		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++];
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

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

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

		char[] next(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);
		}

		int nextInt() {
			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 * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			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();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

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

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		int[][] next2DInt(int n, int m) {
			int[][] arr = new int[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextIntArray(m);
			}
			return arr;
		}

		long[][] next2DLong(int n, int m) {
			long[][] arr = new long[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLongArray(m);
			}
			return arr;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				int c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		long[] shuffle(long[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				long c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		int[] uniq(int[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			int[] rv = new int[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		long[] uniq(long[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			long[] rv = new long[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		int[] reverse(int[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		long[] reverse(long[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		int[] compress(int[] arr) {
			int n = arr.length;
			int[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}

		long[] compress(long[] arr) {
			int n = arr.length;
			long[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}
	}
}

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

public class E implements Runnable {
	boolean judge = false;
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		long n = scn.nextLong(), m = scn.nextLong(), k = n * m;
		long l = scn.nextLong(), r = scn.nextLong(), len = r - l + 1;
		long mod = 998244353;

		if (k % 2 == 1) {
			out.println(pow(len, n * m, mod));
			return;
		}

		long ans = (pow(len, k, mod) + pow(len % 2, k, mod)) * pow(2, mod - 2, mod) % mod;
		out.println(ans);
	}

	long pow(long a, long x, long m) {
		long rv = 1;
		while (x != 0) {
			if ((x & 1) == 1) {
				rv = (rv * a) % m;
			}
			a = (a * a) % m;
			x = x >> 1;
		}
		return rv;
	}

	public void run() {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null || judge;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) {
		new Thread(null, new E(), "Main", 1 << 28).start();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

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

		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++];
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

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

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

		char[] next(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);
		}

		int nextInt() {
			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 * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			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();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

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

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		int[][] next2DInt(int n, int m) {
			int[][] arr = new int[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextIntArray(m);
			}
			return arr;
		}

		long[][] next2DLong(int n, int m) {
			long[][] arr = new long[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLongArray(m);
			}
			return arr;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				int c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		long[] shuffle(long[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				long c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		int[] uniq(int[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			int[] rv = new int[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		long[] uniq(long[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			long[] rv = new long[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		int[] reverse(int[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		long[] reverse(long[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		int[] compress(int[] arr) {
			int n = arr.length;
			int[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}

		long[] compress(long[] arr) {
			int n = arr.length;
			long[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}
	}
}

// package Quarantine;

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

public class HeightAllTheSame {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int m=Integer.parseInt(st.nextToken());
        int l=Integer.parseInt(st.nextToken());
        int r=Integer.parseInt(st.nextToken());
        long total=1l*n*m;
        int mod=998244353;
        if(total%2!=0){
            long ans=modexp(r-l+1,total,mod);
            System.out.println(ans);
        }
        else{
            int k=r-l+1;
            int e=r/2-l/2;
            if(l%2==0){
                e++;
            }
            int o=k-e;
//            System.out.println(e+" "+o);
            long ans=modexp(e+o,total,mod);
            ans=(ans+modexp(e-o,total,mod))%mod;
            ans=(ans*modexp(2,mod-2,mod))%mod;
            System.out.println(ans);
        }
    }
    public static long modexp(long a,long power,int mod){
        if(power==0){
            return 1;
        }
        if(power==1){
            return a;
        }
        long small=modexp(a,power/2,mod);
        long ans=(small%mod*small%mod)%mod;
        if(power%2!=0){
            ans=(ans%mod*a%mod)%mod;
        }
        return ans;
    }
}

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

public class E {

	static long mod = 998244353;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long n = sc.nextInt();
		long m = sc.nextInt();
		long L = sc.nextInt();
		long R = sc.nextInt();
		if(n % 2 == 1 && m % 2 == 1) {
			System.out.println(pow((R-L+1) % mod, n*m));
		}
		else {
			if((R - L + 1) % 2 == 0) {
				long allbutone = pow((R-L+1) % mod, n*m-1);
				long res = allbutone * ((R-L+1)/2) % mod;
				System.out.println(res);
			}
			else { //fun case
				Matrix id = new Matrix(1,0,0,1);
				long k = (R - L + 1) / 2;
				Matrix mat = new Matrix(k, k+1, k+1, k);
				Matrix res = mat.pow(n*m);
				System.out.println(res.mat[0][0]);
			}
		}
	}
	static class Matrix{
		long[][] mat = new long[2][2];
		public Matrix(long a, long b, long c, long d) {
			mat[0][0] = a;
			mat[0][1] = b;
			mat[1][0] = c;
			mat[1][1] = d;
		}
		public Matrix(long[][] mat) {
			this.mat = mat;
		}
		public Matrix pow(long x) {
			Matrix res = new Matrix(1, 0, 0, 1);
			Matrix a = new Matrix(mat);
			while(x > 0) {
				if(x % 2 == 1) {
					res = res.mult(a);
				}
				a = a.mult(a);
				x /= 2;
			}
			return res;
		}
		public Matrix mult(Matrix m) {
			long[][] rmat = new long[2][2];
			for(int i = 0; i < 2; i++) {
				for(int j = 0; j < 2; j++) {
					for(int k = 0; k < 2; k++) {
						rmat[i][j] += mat[i][k] * m.mat[k][j];
						rmat[i][j] %= mod;
					}
				}
			}
			return new Matrix(rmat);
		}
		public String toString() {
			return
			mat[0][0]+" "+mat[0][1]+"\n"+
			mat[1][0]+" "+mat[1][1];
		}
	}

	static long pow(long a, long b) {
		long res = 1;
		while(b > 0) {
			if(b % 2 == 1) {
				res = (res * a) % mod;
			}
			a = (a * a) % mod;
			b /= 2;
		}
		return res;
	}

	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}

//package Div2_630;
//564 558 305171115 960941497

import java.util.Scanner;
import java.util.TreeMap;

public class E {
    static long mod = 998244353;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        long m = in.nextInt();
        long p = in.nextInt();
        long q = in.nextInt();
        long x = q - p + 1;
        if (p % 2 == 0) x = x - x / 2;
        else x /= 2;
        long y = q - p + 1 - x;
        dp[0]=new TreeMap();
        dp[1]=new TreeMap();
        if ((n & m) % 2 == 0) {
            long ans = fn(x, y, n * m, 0);
            System.out.println(ans);
        } else {
            long ans = bin(x + y, n * m);
            System.out.println(ans);
        }
    }

    static TreeMap<Long, Integer>[] dp = new TreeMap[2];

    private static long fn(long x, long y, long st, int type) {
        if (dp[type].containsKey(st)) return dp[type].get(st);
        if (st == 1) {
            if (type == 0) return x;
            return y;
        }
        if (st % 2 == 1) {
            return (x * fn(x, y, st - 1, type) + y * fn(x, y, st - 1, (type + 1) % 2)) % mod;
        } else {
            long nch = fn(x, y, st / 2, 1);
            long ch = fn(x, y, st / 2, 0);
            long ans = 0;
            if (type == 0) {
                ans = (ch * ch + nch * nch) % mod;
            } else {
                ans = (2 * ch * nch) % mod;
            }
            dp[type].put(st, (int) ans);
            return ans;
        }
    }

    private static long bin(long x, long st) {
        if (st == 0) return 1;
        if (st == 1) return x;
        long m = st / 2;
        long ans = bin(x, m);
        if (st % 2 == 0) {
            return (ans * ans) % mod;
        } else {
            return (((ans * ans) % mod) * x) % mod;
        }
    }
}

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Map.Entry;

import java.util.Random;
import java.util.TreeSet;

public final class CF_630_D2_E
{

	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputFlush(Object o){try {out.write(""+ o+"\n");out.flush();} catch (Exception e) {}}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}

	// Global vars
	static BufferedWriter out;
	static InputReader reader;

	static void test() {
		log("testing");

		Random r=new Random();
		int NTESTS=100000;
		int NMAX=100;
		for (int t=0;t<NTESTS;t++) {

		}

		log("done");

	}

	static int st;

	static class Composite implements Comparable<Composite>{

		long v;
		int idx;
		long x;
		long d;

		public int compareTo(Composite X) {
			if (v<X.v)
				return -1;
			if (v>X.v)
				return 1;
			return idx-X.idx;
		}

		public Composite(long v, int idx, long x, long d) {
			this.v = v;
			this.idx = idx;
			this.x = x;
			this.d = d;
		}

	}

	static long powerMod(long b,long e,long m){
		long x=1;
		while (e>0) {
			if (e%2==1)
				x=(b*x)%m;
			b=(b*b)%m;
			e=e/2;
		}
		return x;
	}

	static void process() throws Exception {

		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader = new InputReader(System.in);

		long n=reader.readInt();
		long m=reader.readInt();
		int L=reader.readInt();
		int R=reader.readInt();

		long mod=998244353;
		long inv2=powerMod(2,mod-2,mod);

		long ans=0;
		long nm=n*m;

		// solution
		// case 1: if at least one set is even, we can achieve
		// case 2! problem is if both set are odd size. In this case it does not work...
		// if n*m is odd, we are always case 1
		// if n*m is even, depends..

		long diff=R-L+1;
		long p1=diff/2;
		long p2=diff-p1;
		if (nm%2==1) {
			// whatever the distribution it will work
			ans=powerMod(diff,nm,mod);

		} else {
			// A+B = nm
			// A even, B good
			// A in 2,4...nm,

			long pp1=diff;
			long pp2=Math.abs(p1-p2);

			long opt1=powerMod(pp1,nm,mod);
			long opt2=powerMod(pp2,nm,mod);
			long opt=opt1+opt2;
			opt%=mod;
			opt*=inv2;
			opt%=mod;
			ans=opt;

		}
		output(ans);

		try {
			out.close();
		} catch (Exception Ex) {
		}

	}

	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final String readString(int L) throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder(L);
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}

}
/*

5
1 4 5 2 3

 */

// package algorithm.div630;

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

/**
 * Created with: IntelliJ IDEA
 * Function:
 * User: zhangzhe041@ke.com
 * Date: 2020-04-06 10:08:07
 */

//494587372 852064625 134519483 167992226
public class HeightAllTheSamePlus {

    long n,m,l,r;

    int mod = 998_244_353;

    public static void main(String[] args) throws IOException {
        new HeightAllTheSamePlus();

    }
    HeightAllTheSamePlus() throws IOException {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n = in.nextLong();
        m = in.nextLong();
        l = in.nextLong();
        r  =in.nextLong();
        //long tmp = n * m;
        Long x = (r - l + 1) / 2;
        Long y = (r - l +1) - x;
        if(((n * m) & 1) == 1){
            out.print(pow2(r - l + 1, n * m));
        }else{
            out.print((pow2(x + y, n * m) + pow2(x - y, n * m)) * pow2(2, mod - 2) % mod);
        }
        out.close();
    }

    long pow2(long a, long b){
        long base = a;
        long ans = 1;
        while(b > 0){

            if((b & 1) == 1){
                ans = ans * base % mod;
            }
            b = b >> 1;
            base = base * base % mod;
        }
        return ans;
    }

    class Scanner{
        BufferedReader br;
        StringTokenizer st;

        Scanner(InputStream inputStream){br = new BufferedReader(new InputStreamReader(inputStream));}

        String next() throws IOException {
            if(st == null || !st.hasMoreTokens()){
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

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

        Long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}

import java.util.*;
import java.io.*;
public class e {
	static final long mod = 998_244_353;

	static long num, L, R;
	static long numEven, numOdd;
	static long[][] mat;
	public static void main(String[] args) {
		FS sc = new FS();
		num = sc.nextLong() * sc.nextLong();
		L = sc.nextLong();
		R = sc.nextLong();

		if(num % 2 == 1) {
			long out = pow(R - L + 1, num);
			System.out.println(out);
			return;
		}

		numEven = numOdd = (R - L + 1) / 2;
		if(L % 2 == R % 2) {
			if(L % 2 == 0) ++numEven;
			else ++numOdd;
		}

		mat = new long[2][2];
		mat[0][0] = mat[1][1] = numEven % mod;
		mat[0][1] = mat[1][0] = numOdd % mod;

		// do the thing
		long[][] out = pow(mat, num);

		System.out.println(out[0][0]);
	}
	static long[][] pow(long[][] a, long pow){
		long[][] out = new long[2][2];
		if(pow == 0) {
			out[0][0] = out[1][1] = 1;
			return out;
		}

		out = pow(a, pow / 2);
		out = mult(out, out);
		if(pow % 2 == 1) out = mult(out, a);
		return out;
	}
	static long[][] mult(long[][] a, long[][] b){
		long[][] out = new long[2][2];
		for(int i = 0; i < 2; ++i) {
			for(int j = 0; j < 2; ++j) {
				// dot product of row i of a and col j of b
				long curr = 0;
				for(int k = 0; k < 2; ++k) curr = (curr + a[i][k] * b[k][j]) % mod;
				out[i][j] = curr;
			}
		}
		return out;
	}
	static long pow(long a, long pow) {
		if(pow == 0) return 1;

		long out = pow(a, pow / 2);
		out = (out * out) % mod;
		if(pow % 2 == 1) out = (out * a) % mod;
		return out;
	}
	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}
/*
2 2 1 3

2 2 3 5

1 3 1 2

*/

import java.util.*;
import java.io.*;
public class EdD {
	static long[] mods = {1000000007, 998244353, 1000000009};
	static long mod = mods[1];
	public static MyScanner sc;
    public static PrintWriter out;
	public static void main(String[] omkar) throws Exception{
		// TODO Auto-generated method stub
 		sc = new MyScanner();
 		PrintWriter out = new PrintWriter(System.out);
 		long n = sc.nextLong();
 		long m = sc.nextLong();
 		long l = sc.nextLong();
 		long r = sc.nextLong();
 		long ans = power((r-l+1)%mod, n*m);
 		if ((n*m)%2 == 0){
 			if (r%2 == l%2)
 				ans+=1;
			ans*=power(2, mod-2);
			ans%=mod;
 		}
 		out.println(ans);

 		out.close();
 	}
	public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<Integer>();
		for (int i : array)
			copy.add(i);
		Collections.sort(copy);
		for(int i = 0;i<array.length;i++)
			array[i] = copy.get(i);
	}
	static String[] readArrayString(int n){
		String[] array = new String[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.next();
		return array;
	}
	static int[] readArrayInt(int n){
    	int[] array = new int[n];
    	for(int j = 0;j<n;j++)
    		array[j] = sc.nextInt();
    	return array;
    }
	static int[] readArrayInt1(int n){
		int[] array = new int[n+1];
		for(int j = 1;j<=n;j++){
			array[j] = sc.nextInt();
		}
		return array;
	}
	static long[] readArrayLong(int n){
		long[] array = new long[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextLong();
		return array;
	}
	static double[] readArrayDouble(int n){
		double[] array = new double[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextDouble();
		return array;
	}
	static int minIndex(int[] array){
		int minValue = Integer.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(long[] array){
		long minValue = Long.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(double[] array){
		double minValue = Double.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static long power(long x, long y){
		if (y == 0)
			return 1;
		if (y%2 == 1)
			return (x*power(x, y-1))%mod;
		return power((x*x)%mod, y/2)%mod;
	}
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

import java.util.*;
import java.io.*;
import java.security.acl.Owner;

public class codeforces {

	public static void main(String[] args) throws Exception {
		long n=sc.nextLong();
		long m=sc.nextLong();
		long l=sc.nextLong();
		long r=sc.nextLong();
		long k=1l*r-l+1;
		long num=1l*n*m;
		long even=k/2;
		long odd=k/2;
//		fac=new long[(int) k];
//		fac[0]=1;
//		fac[1]=1;
//		for(int i=2;i<k;i++) {
//			fac[i]=(fac[i-1]*i)%mod;
//		}
		if(k%2==1) {
		if(l%2==1) {
			odd++;
		}else {
			even++;
		}

		}

		long ans=0;
		if(num%2==1) {
			ans=Pow(k, num, mod);
			pw.println(ans);
		}
		else {
			if(odd>even) {
			ans=(((1l*Pow(odd+even, num, mod)+mod+Pow(odd-even, num, mod))%mod)*Pow(2, mod - 2, mod))%mod;
			}else if(even>odd){

				ans=(((1l*Pow(odd+even, num, mod)+mod+Pow(even-odd, num, mod))%mod)*Pow(2, mod - 2, mod))%mod;
			}else {
				ans=(((1l*Pow(odd+even, num, mod)+mod+Pow(even-odd, num, mod))%mod)*Pow(2, mod - 2, mod))%mod;
			}
			pw.println(ans);

		}
		pw.close();
	}
    static class Scanner {

        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int curbuf;
        private int lenbuf;

        public Scanner(InputStream in) {
            this.in = in;
            this.curbuf = this.lenbuf = 0;
        }

        public boolean hasNextByte() {
            if (curbuf >= lenbuf) {
                curbuf = 0;
                try {
                    lenbuf = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0)
                    return false;
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[curbuf++];
            else
                return -1;
        }

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

        private void skip() {
            while (hasNextByte() && isSpaceChar(buffer[curbuf]))
                curbuf++;
        }

        public boolean hasNext() {
            skip();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (!isSpaceChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

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

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

    }

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	public static long GCD(long a, long b) {
		if (b == 0)
			return a;
		if (a == 0)
			return b;
		return (a > b) ? GCD(a % b, b) : GCD(a, b % a);
	}

	public static long LCM(long a, long b) {
		return a * b / GCD(a, b);
	}

	static long Pow(long a, long e, int mod) // O(log e)
	{
		a %= mod;
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static long nc(int n, int r) {
		if (n < r)
			return 0;
		long v = fac[n];
		v *= Pow(fac[r], mod - 2, mod);
		v %= mod;
		v *= Pow(fac[n - r], mod - 2, mod);
		v %= mod;
		return v;
	}

	public static boolean isprime(long a) {
		if (a == 0 || a == 1) {
			return false;
		}
		if (a == 2) {
			return true;
		}
		for (int i = 2; i < Math.sqrt(a) + 1; i++) {
			if (a % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static boolean isPal(String s) {
		boolean t = true;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				t = false;
				break;
			}
		}
		return t;
	}

	public static long RandomPick(long[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static int RandomPick(int[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static void PH(String s, boolean reverse) {
		prelen = s.length();
		HashsArray[HashsArrayInd] = new int[prelen + 1];
		prepow = new int[prelen];
		if (HashsArrayInd == 0) {
			int[] mods = { 1173017693, 1173038827, 1173069731, 1173086977, 1173089783, 1173092147, 1173107093,
					1173114391, 1173132347, 1173144367, 1173150103, 1173152611, 1173163993, 1173174127, 1173204679,
					1173237343, 1173252107, 1173253331, 1173255653, 1173260183, 1173262943, 1173265439, 1173279091,
					1173285331, 1173286771, 1173288593, 1173298123, 1173302129, 1173308827, 1173310451, 1173312383,
					1173313571, 1173324371, 1173361529, 1173385729, 1173387217, 1173387361, 1173420799, 1173421499,
					1173423077, 1173428083, 1173442159, 1173445549, 1173451681, 1173453299, 1173454729, 1173458401,
					1173459491, 1173464177, 1173468943, 1173470041, 1173477947, 1173500677, 1173507869, 1173522919,
					1173537359, 1173605003, 1173610253, 1173632671, 1173653623, 1173665447, 1173675577, 1173675787,
					1173684683, 1173691109, 1173696907, 1173705257, 1173705523, 1173725389, 1173727601, 1173741953,
					1173747577, 1173751499, 1173759449, 1173760943, 1173761429, 1173762509, 1173769939, 1173771233,
					1173778937, 1173784637, 1173793289, 1173799607, 1173802823, 1173808003, 1173810919, 1173818311,
					1173819293, 1173828167, 1173846677, 1173848941, 1173853249, 1173858341, 1173891613, 1173894053,
					1173908039, 1173909203, 1173961541, 1173968989, 1173999193 };
			mod = RandomPick(mods);
			int[] primes = { 59, 61, 67, 71, 73, 79, 83, 89, 97, 101 };
			prime = RandomPick(primes);
		}
		prepow[0] = 1;
		if (!reverse) {

			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
			}

		} else {
			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[prelen - 1 - i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);

			}

		}

		HashsArrayInd++;

	}

	public static int PHV(int l, int r, int n, boolean reverse) {
		if (l > r) {
			return 0;
		}
		int val = (int) ((1l * HashsArray[n - 1][r] + mod - HashsArray[n - 1][l - 1]) % mod);
		if (!reverse) {

			val = (int) ((1l * val * prepow[prelen - l]) % mod);
		} else {
			val = (int) ((1l * val * prepow[r - 1]) % mod);
		}
		return val;
	}
	 static int modInverse(long a, int m)
	    {
	        a = a % m;
	        for (int x = 1; x < m; x++)
	           if ((a * x) % m == 1)
	              return x;
	        return 1;
	    }
	static int[][] HashsArray;
	static int HashsArrayInd = 0;
	static int[] prepow;
	static int prelen = 0;
	static int prime = 31;
	static long fac[];
	static int mod = 998244353;
	static Random rn = new Random();
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);
}

import java.util.*;
import java.io.*;
import java.security.acl.Owner;

public class codeforces {

	public static void main(String[] args) throws Exception {
		long n=sc.nextLong();
		long m=sc.nextLong();
		long l=sc.nextLong();
		long r=sc.nextLong();
		long k=1l*r-l+1;
		long num=1l*n*m;
		long even=k/2;
		long odd=k/2;
//		fac=new long[(int) k];
//		fac[0]=1;
//		fac[1]=1;
//		for(int i=2;i<k;i++) {
//			fac[i]=(fac[i-1]*i)%mod;
//		}
		if(k%2==1) {
		if(l%2==1) {
			odd++;
		}else {
			even++;
		}

		}

		long ans=0;
		if(num%2==1) {
			ans=Pow(k, num, mod);
			pw.println(ans);
		}
		else {
			if(odd>even) {
			ans=(((1l*Pow(odd+even, num, mod)+mod-Pow(odd-even, num, mod))%mod)*Pow(2, mod - 2, mod)+1)%mod;
			}else if(even>odd){

				ans=(((1l*Pow(odd+even, num, mod)+mod-Pow(even-odd, num, mod))%mod)*Pow(2, mod - 2, mod)+1)%mod;
			}else {
				ans=(((1l*Pow(odd+even, num, mod)+mod-Pow(even-odd, num, mod))%mod)*Pow(2, mod - 2, mod))%mod;
			}
			pw.println(ans);

		}
		pw.close();
	}
    static class Scanner {

        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int curbuf;
        private int lenbuf;

        public Scanner(InputStream in) {
            this.in = in;
            this.curbuf = this.lenbuf = 0;
        }

        public boolean hasNextByte() {
            if (curbuf >= lenbuf) {
                curbuf = 0;
                try {
                    lenbuf = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0)
                    return false;
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[curbuf++];
            else
                return -1;
        }

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

        private void skip() {
            while (hasNextByte() && isSpaceChar(buffer[curbuf]))
                curbuf++;
        }

        public boolean hasNext() {
            skip();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (!isSpaceChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

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

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

    }

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	public static long GCD(long a, long b) {
		if (b == 0)
			return a;
		if (a == 0)
			return b;
		return (a > b) ? GCD(a % b, b) : GCD(a, b % a);
	}

	public static long LCM(long a, long b) {
		return a * b / GCD(a, b);
	}

	static long Pow(long a, long e, int mod) // O(log e)
	{
		a %= mod;
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static long nc(int n, int r) {
		if (n < r)
			return 0;
		long v = fac[n];
		v *= Pow(fac[r], mod - 2, mod);
		v %= mod;
		v *= Pow(fac[n - r], mod - 2, mod);
		v %= mod;
		return v;
	}

	public static boolean isprime(long a) {
		if (a == 0 || a == 1) {
			return false;
		}
		if (a == 2) {
			return true;
		}
		for (int i = 2; i < Math.sqrt(a) + 1; i++) {
			if (a % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static boolean isPal(String s) {
		boolean t = true;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				t = false;
				break;
			}
		}
		return t;
	}

	public static long RandomPick(long[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static int RandomPick(int[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static void PH(String s, boolean reverse) {
		prelen = s.length();
		HashsArray[HashsArrayInd] = new int[prelen + 1];
		prepow = new int[prelen];
		if (HashsArrayInd == 0) {
			int[] mods = { 1173017693, 1173038827, 1173069731, 1173086977, 1173089783, 1173092147, 1173107093,
					1173114391, 1173132347, 1173144367, 1173150103, 1173152611, 1173163993, 1173174127, 1173204679,
					1173237343, 1173252107, 1173253331, 1173255653, 1173260183, 1173262943, 1173265439, 1173279091,
					1173285331, 1173286771, 1173288593, 1173298123, 1173302129, 1173308827, 1173310451, 1173312383,
					1173313571, 1173324371, 1173361529, 1173385729, 1173387217, 1173387361, 1173420799, 1173421499,
					1173423077, 1173428083, 1173442159, 1173445549, 1173451681, 1173453299, 1173454729, 1173458401,
					1173459491, 1173464177, 1173468943, 1173470041, 1173477947, 1173500677, 1173507869, 1173522919,
					1173537359, 1173605003, 1173610253, 1173632671, 1173653623, 1173665447, 1173675577, 1173675787,
					1173684683, 1173691109, 1173696907, 1173705257, 1173705523, 1173725389, 1173727601, 1173741953,
					1173747577, 1173751499, 1173759449, 1173760943, 1173761429, 1173762509, 1173769939, 1173771233,
					1173778937, 1173784637, 1173793289, 1173799607, 1173802823, 1173808003, 1173810919, 1173818311,
					1173819293, 1173828167, 1173846677, 1173848941, 1173853249, 1173858341, 1173891613, 1173894053,
					1173908039, 1173909203, 1173961541, 1173968989, 1173999193 };
			mod = RandomPick(mods);
			int[] primes = { 59, 61, 67, 71, 73, 79, 83, 89, 97, 101 };
			prime = RandomPick(primes);
		}
		prepow[0] = 1;
		if (!reverse) {

			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
			}

		} else {
			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[prelen - 1 - i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);

			}

		}

		HashsArrayInd++;

	}

	public static int PHV(int l, int r, int n, boolean reverse) {
		if (l > r) {
			return 0;
		}
		int val = (int) ((1l * HashsArray[n - 1][r] + mod - HashsArray[n - 1][l - 1]) % mod);
		if (!reverse) {

			val = (int) ((1l * val * prepow[prelen - l]) % mod);
		} else {
			val = (int) ((1l * val * prepow[r - 1]) % mod);
		}
		return val;
	}
	 static int modInverse(long a, int m)
	    {
	        a = a % m;
	        for (int x = 1; x < m; x++)
	           if ((a * x) % m == 1)
	              return x;
	        return 1;
	    }
	static int[][] HashsArray;
	static int HashsArrayInd = 0;
	static int[] prepow;
	static int prelen = 0;
	static int prime = 31;
	static long fac[];
	static int mod = 998244353;
	static Random rn = new Random();
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);
}

import java.util.*;
import java.io.*;
import java.security.acl.Owner;

public class codeforces {

	public static void main(String[] args) throws Exception {
		long n=sc.nextLong();
		long m=sc.nextLong();
		long l=sc.nextLong();
		long r=sc.nextLong();
		long k=1l*r-l+1;
		long num=1l*n*m;
		long even=k/2;
		long odd=k/2;
//		fac=new long[(int) k];
//		fac[0]=1;
//		fac[1]=1;
//		for(int i=2;i<k;i++) {
//			fac[i]=(fac[i-1]*i)%mod;
//		}
		if(k%2==1) {
		if(l%2==1) {
			odd++;
		}else {
			even++;
		}

		}

		long ans=0;
		if(num%2==1) {
			ans=Pow(k, num, mod);
			pw.println(ans);
		}
		else {
			if(odd>even) {
			ans=((1l*Pow(odd+even, num, mod)+1)*Pow(2, mod - 2, mod))%mod;
			}else if(even>odd){

				ans=((1l*Pow(odd+even, num, mod)+1)*Pow(2, mod - 2, mod))%mod;
			}else {
				ans=(1l*Pow(odd+even, num, mod)*Pow(2, mod - 2, mod))%mod;
			}
			pw.println(ans);

		}
		pw.close();
	}
    static class Scanner {

        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int curbuf;
        private int lenbuf;

        public Scanner(InputStream in) {
            this.in = in;
            this.curbuf = this.lenbuf = 0;
        }

        public boolean hasNextByte() {
            if (curbuf >= lenbuf) {
                curbuf = 0;
                try {
                    lenbuf = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0)
                    return false;
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[curbuf++];
            else
                return -1;
        }

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

        private void skip() {
            while (hasNextByte() && isSpaceChar(buffer[curbuf]))
                curbuf++;
        }

        public boolean hasNext() {
            skip();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (!isSpaceChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

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

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

    }

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	public static long GCD(long a, long b) {
		if (b == 0)
			return a;
		if (a == 0)
			return b;
		return (a > b) ? GCD(a % b, b) : GCD(a, b % a);
	}

	public static long LCM(long a, long b) {
		return a * b / GCD(a, b);
	}

	static long Pow(long a, long e, int mod) // O(log e)
	{
		a %= mod;
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static long nc(int n, int r) {
		if (n < r)
			return 0;
		long v = fac[n];
		v *= Pow(fac[r], mod - 2, mod);
		v %= mod;
		v *= Pow(fac[n - r], mod - 2, mod);
		v %= mod;
		return v;
	}

	public static boolean isprime(long a) {
		if (a == 0 || a == 1) {
			return false;
		}
		if (a == 2) {
			return true;
		}
		for (int i = 2; i < Math.sqrt(a) + 1; i++) {
			if (a % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static boolean isPal(String s) {
		boolean t = true;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				t = false;
				break;
			}
		}
		return t;
	}

	public static long RandomPick(long[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static int RandomPick(int[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static void PH(String s, boolean reverse) {
		prelen = s.length();
		HashsArray[HashsArrayInd] = new int[prelen + 1];
		prepow = new int[prelen];
		if (HashsArrayInd == 0) {
			int[] mods = { 1173017693, 1173038827, 1173069731, 1173086977, 1173089783, 1173092147, 1173107093,
					1173114391, 1173132347, 1173144367, 1173150103, 1173152611, 1173163993, 1173174127, 1173204679,
					1173237343, 1173252107, 1173253331, 1173255653, 1173260183, 1173262943, 1173265439, 1173279091,
					1173285331, 1173286771, 1173288593, 1173298123, 1173302129, 1173308827, 1173310451, 1173312383,
					1173313571, 1173324371, 1173361529, 1173385729, 1173387217, 1173387361, 1173420799, 1173421499,
					1173423077, 1173428083, 1173442159, 1173445549, 1173451681, 1173453299, 1173454729, 1173458401,
					1173459491, 1173464177, 1173468943, 1173470041, 1173477947, 1173500677, 1173507869, 1173522919,
					1173537359, 1173605003, 1173610253, 1173632671, 1173653623, 1173665447, 1173675577, 1173675787,
					1173684683, 1173691109, 1173696907, 1173705257, 1173705523, 1173725389, 1173727601, 1173741953,
					1173747577, 1173751499, 1173759449, 1173760943, 1173761429, 1173762509, 1173769939, 1173771233,
					1173778937, 1173784637, 1173793289, 1173799607, 1173802823, 1173808003, 1173810919, 1173818311,
					1173819293, 1173828167, 1173846677, 1173848941, 1173853249, 1173858341, 1173891613, 1173894053,
					1173908039, 1173909203, 1173961541, 1173968989, 1173999193 };
			mod = RandomPick(mods);
			int[] primes = { 59, 61, 67, 71, 73, 79, 83, 89, 97, 101 };
			prime = RandomPick(primes);
		}
		prepow[0] = 1;
		if (!reverse) {

			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
			}

		} else {
			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[prelen - 1 - i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);

			}

		}

		HashsArrayInd++;

	}

	public static int PHV(int l, int r, int n, boolean reverse) {
		if (l > r) {
			return 0;
		}
		int val = (int) ((1l * HashsArray[n - 1][r] + mod - HashsArray[n - 1][l - 1]) % mod);
		if (!reverse) {

			val = (int) ((1l * val * prepow[prelen - l]) % mod);
		} else {
			val = (int) ((1l * val * prepow[r - 1]) % mod);
		}
		return val;
	}
	 static int modInverse(long a, int m)
	    {
	        a = a % m;
	        for (int x = 1; x < m; x++)
	           if ((a * x) % m == 1)
	              return x;
	        return 1;
	    }
	static int[][] HashsArray;
	static int HashsArrayInd = 0;
	static int[] prepow;
	static int prelen = 0;
	static int prime = 31;
	static long fac[];
	static int mod = 998244353;
	static Random rn = new Random();
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {

    static int mod = 998_244_353;
    static long pow(long a,long n) {
        long res=1;
        while (n>0) {
            if ((n-n/2*2)==1) {
                res=res*a%mod;
            }
            a=a*a%mod;
            n>>=1;
        }
        return res;
    }

    static long modinv(long n) {
        return pow(n, mod-2);
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        long n = in.nextLong();
        long m = in.nextLong();
        long L = in.nextLong();
        long R = in.nextLong();
        if (n*m%2==1) {
            out.println(pow(R-L+1, n*m));
        } else { // n*m%2==0
            long tmp = pow(R-L+1, n*m);
            if ((R-L+1)%2==1) tmp=(tmp+1)%mod;
            out.println(tmp*modinv(2)%mod);
        }

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}

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

public class tr0 {
	static PrintWriter out;
	static StringBuilder sb;
	static long mod = 998244353;
	static int inf = (int) 1e15;
	static ArrayList<Integer>[] ad;
	static int n, r, m;
	static int[][] memo, grid;
	static char[][] g;
	static boolean[] vis;
	static long ans, tem;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		long n = sc.nextInt();
		long m = sc.nextInt();
		long l = sc.nextInt();
		long r = sc.nextInt();
		long all = modPow(r - l + 1, n * m);
		if(n*m%2==1) {
			System.out.println(all);
			return;
		}
		long od = ((r + 1) / 2) - (l / 2);
		long ev = (r / 2) - ((l - 1) / 2);
		long d2 = (modPow((od + ev), n * m) +modPow((od - ev), n * m))%mod ;
		System.out.println((d2 * modPow(2, mod-2)) % mod);
		out.close();
	}

	static long modPow(long a, long e)

	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

public class e{

	static long mod = 998244353;

	public static void main(String[] args){
		JS scan = new JS();
		long n = scan.nextLong();
		long m = scan.nextLong();
		long L = scan.nextLong();
		long R = scan.nextLong();
		long h = R-L;

		long e = 0;
		long o = 0;
		if(h % 2 == 1){
			long d = (h+1)/2;
			e = d;
			o = d;
		}
		else{
			long d = h/2;
			e = d;
			o = d;
			if(L % 2 == 1) o++;
			else e++;
		}

		long[][] mat = {{e, o},{o, e}};
		long[][] pphard = pow(mat, m*n);
		long ans = pphard[0][0];
		if((n*m)%2==1) ans += pphard[0][1];
		System.out.println(ans%mod);
	}

	static long[][] pow(long[][] a, long pow){
		if(pow == 0) return iden(a.length);
		if(pow % 2 == 1){
			long[][] res = pow(a, pow-1);
			return mult(res, a);
		}
		long[][] res = pow(a, pow/2);
		return mult(res, res);
	}

	static long[][] iden(int n){
		long[][] res = new long[n][n];
		for(int i = 0; i < n; i++) res[i][i] = 1;
		return res;
	}

	static long[][] mult(long[][] a, long[][] b){
		long[][] res = new long[a.length][b[0].length];
		for(int i = 0; i < a.length; i++){
			for(int j = 0; j < b[0].length; j++){
				for(int k = 0; k < a[0].length; k++){
					res[i][j] += (a[i][k]%mod)*(b[k][j]%mod);
					res[i][j] %= mod;
				}
			}
		}
		return res;
	}

	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}

}

import java.util.Scanner;

public class a {
    static long mod = 998244353;

    static long fpow(long x, long n) {
        long res = 1;
        x %= mod;
        while (n > 0) {
            if ((n & 1) == 1)
                res = res * x % mod;
            x = x * x % mod;
            n >>= 1;
        }
        return res;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        long m = in.nextInt();
        long L = in.nextInt();
        long R = in.nextInt();
        long ans = fpow(R - L + 1, n * m);
        if ((n * m) % 2 == 0) {
            if ((R - L + 1) % 2 == 1)
                ans++;
            ans = ans * fpow(2, mod - 2) % mod;
        }
        System.out.println(ans);
        in.close();
    }
}

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

public class HeightAllTheSame {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(in.readLine());
		long N = Long.parseLong(st.nextToken());
		long M = Long.parseLong(st.nextToken());
		long L = Long.parseLong(st.nextToken());
		long R = Long.parseLong(st.nextToken());
		if((N * M) % 2 == 1) {
			out.println(pow(R - L + 1, N * M));
		} else if((R - L + 1) % 2 == 0) {
			out.println((pow(R - L + 1, N * M) * (long)(998244353 + 1) / 2) % 998244353);
		} else {
			out.println(((pow(R - L + 1, N * M) + 1) * (long)(998244353 + 1) / 2) % 998244353);
		}
		in.close();
		out.close();
	}
	static long pow(long a, long b) {
		long res = 1;
		while(b > 0) {
			if(b % 2 == 1) {
				res = (res * a) % 998244353;
				b--;
			}
			a = (a * a) % 998244353;
			b /= 2;
		}
		return res;
	}
}

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

public class Drogon {
    public static void main(String[] args) throws Exception {
        FastReader sc=new FastReader();
        long n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt(),r=sc.nextInt();
        long mod=998244353;
        if ((n*m)%2==1){
            System.out.println(pow(r-l+1,n*m,mod));
        }else {
            long k=r-l;
            long o=(k+1)/2,e=k+1-o;
            long inv=pow(2,mod-2,mod);
            long ans=(inv*((pow(o+e,n*m,mod)+pow(Math.abs(o-e),n*m,mod))%mod))%mod;
            System.out.println(ans);
        }
    }
    static long pow(long a,long pow,long mod){
        if (pow==0)return 1;
        long res=pow(a,pow/2,mod)%mod;
        if (pow%2==0)return (res*res)%mod;
        return (((res*res)%mod)*a)%mod;
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.util.*;
import java.lang.*;
import java.io.*;
// StringBuilder uses java.lang

public class mC {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        int c = sc.nextInt();
        int d = sc.nextInt();
        long MODULO = 998244353;
        long x = 0;
        if (a%2==0 || b%2==0) {
            if ((d-c)%2 == 0) {
                if (d%2 == 0) {
                    x = (fastPow(d-c+1,a*b,MODULO)+1)*(998244354/2);
                } else {
                    x = (fastPow(d-c+1,a*b,MODULO)+1)*(998244354/2);
                }
            } else {
                x = (fastPow(d-c+1,a*b,MODULO))*(998244354/2);
            }
        } else {
            x = fastPow(d-c+1,a*b,MODULO);
        }
        System.out.println(x%MODULO);

    }
    public static int whichToSub(int[][] arr, int at,ArrayList<ArrayList<Integer>> con) {
        for (int i=0;i<con.get(at).size();i++) {
            if (arr[con.get(at).get(i)][1]!=-1) {
                return con.get(at).get(i);
            }
        }
        return -1;
    }
    public static int findNthInArray(int[] arr,int val,int start,int o) {
        if (o==0) {
            return start-1;
        } else if (arr[start] == val) {
            return findNthInArray(arr,val,start+1,o-1);
        } else {
            return findNthInArray(arr,val,start+1,o);
        }
    }
    public static ArrayList<Integer> dfs(int at,ArrayList<Integer> went,ArrayList<ArrayList<Integer>> connect) {
        for (int i=0;i<connect.get(at).size();i++) {
            if (!(went.contains(connect.get(at).get(i)))) {
                went.add(connect.get(at).get(i));
                went=dfs(connect.get(at).get(i),went,connect);
            }
        }
        return went;
    }
    public static int[][] bfs (int at, int[][] went, ArrayList<ArrayList<Integer>> queue, int numNodes, ArrayList<ArrayList<Integer>> connect) {
        if (went[at][0]==-2) {
            went[at][0]=queue.get(numNodes).get(1);
            for (int i=0;i<connect.get(at).size();i++) {
                if (went[connect.get(at).get(i)][0]==-2) {
                    went[at][1]+=1;
                    ArrayList<Integer> temp = new ArrayList<>();
                    temp.add(connect.get(at).get(i));
                    temp.add(at);
                    queue.add(temp);
                }
            }

        }
        if (queue.size()==numNodes+1) {
            return went;
        } else {
            return bfs(queue.get(numNodes+1).get(0), went, queue, numNodes+1, connect);
        }
    }
    public static long fastPow(int base,long exp,long mod) {
        if (exp==0) {
            return 1;
        } else {
            if (exp % 2 == 1) {
                long z = fastPow(base,(exp-1)/2,mod);
                return ((((z*base) % mod) * z) % mod);
            } else {
                long z = fastPow(base,exp/2,mod);
                return ((z*z) % mod);
            }
        }
    }
    public static long fastPow(long base,long exp) {
        if (exp==0) {
            return 1;
        } else {
            if (exp % 2 == 1) {
                long z = fastPow(base,(exp-1)/2);
                return ((((z*base)) * z));
            } else {
                long z = fastPow(base,exp/2);
                return ((z*z));
            }
        }
    }
    public static int firstLarger(int val,ArrayList<Integer> ok,int left,int right) {
        if (ok.get(right)<=val) {
            return -1;
        }
        if (left==right) {
            return left;
        } else if (left+1==right) {
            if (val<ok.get(left)) {
                return left;
            } else {
                return right;
            }
        } else {
            int mid = (left+right)/2;
            if (ok.get(mid)>val) {
                return firstLarger(val,ok,left,mid);
            } else {
                return firstLarger(val,ok,mid+1,right);
            }
        }
    }
}

/*****Author: Satyajeet Singh, Delhi Technological University************************************/
    import java.io.*;
    import java.util.*;
    import java.text.*;
    import java.lang.*;
    import java.math.*;
public class Main{
/*********************************************Constants******************************************/
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static long mod=(long)1e9+7;
    static long mod1=998244353;
    static HashSet<Integer> graph[];
    static int pptr=0,pptrmax=0;
    static String st[];
/*****************************************Solutions Begins***************************************/
    public static void main(String args[]) throws Exception{
        long n=pl();
        long m=pl();
        long l=pl();
        long r=pl();
        long d=r-l+1;
        long a=d/2;
        long b=d-a;
        long nm=n*m;
        mod=mod1;
        //debug(a,b);

        long ans=(modulo((a+b),nm,mod)+modulo(Math.abs(a-b),nm,mod))%mod;
        ans=(ans*modulo(2l,mod-2,mod))%mod;
        if(nm%2==1){
            ans=modulo(d,nm,mod);
        }
        out.println(ans);
/****************************************Solutions Ends**************************************************/
        out.flush();
        out.close();
    }
/****************************************Template Begins************************************************/
    static void nl() throws Exception{
        pptr=0;
        st=br.readLine().split(" ");
        pptrmax=st.length;
    }
    static void nls() throws Exception{
        pptr=0;
        st=br.readLine().split("");
        pptrmax=st.length;
    }
    static int pi() throws Exception{
        if(pptr==pptrmax)
            nl();
        return Integer.parseInt(st[pptr++]);
    }
    static long pl() throws Exception{
        if(pptr==pptrmax)
            nl();
        return Long.parseLong(st[pptr++]);
    }
    static double pd() throws Exception{
        if(pptr==pptrmax)
            nl();
        return Double.parseDouble(st[pptr++]);
    }
    static String ps() throws Exception{
        if(pptr==pptrmax)
            nl();
        return st[pptr++];
    }
/***************************************Precision Printing**********************************************/
    static void printPrecision(double d){
        DecimalFormat ft = new DecimalFormat("0.000000000000");
        out.print(ft.format(d));
    }
/**************************************Bit Manipulation**************************************************/
    static void printMask(long mask){
        System.out.println(Long.toBinaryString(mask));
    }
    static int countBit(long mask){
        int ans=0;
        while(mask!=0){
            mask&=(mask-1);
            ans++;
        }
        return ans;
    }
/******************************************Graph*********************************************************/
    static void Makegraph(int n){
        graph=new HashSet[n];
        for(int i=0;i<n;i++){
            graph[i]=new HashSet<>();
        }
    }
    static void addEdge(int a,int b){
        graph[a].add(b);
    }
    // static void addEdge(int a,int b,int c){
    //     graph[a].add(new Pair(b,c));
    // }
/*********************************************PAIR********************************************************/
    static class Pair implements Comparable<Pair> {
        int u;
        int v;
        int index=-1;
        public Pair(int u, int v) {
            this.u = u;
            this.v = v;
        }
        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return 31 * hu + hv;
        }
        public boolean equals(Object o) {
            Pair other = (Pair) o;
            return u == other.u && v == other.v;
        }
        public int compareTo(Pair other) {
            if(index!=other.index)
                return Long.compare(index, other.index);
            return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
        }
        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }
    }
/******************************************Long Pair*******************************************************/
    static class Pairl implements Comparable<Pairl> {
            long u;
            long v;
            int index=-1;
            public Pairl(long u, long v) {
                this.u = u;
                this.v = v;
            }
            public int hashCode() {
                int hu = (int) (u ^ (u >>> 32));
                int hv = (int) (v ^ (v >>> 32));
                return 31 * hu + hv;
            }
            public boolean equals(Object o) {
                Pairl other = (Pairl) o;
                return u == other.u && v == other.v;
            }
            public int compareTo(Pairl other) {
                if(index!=other.index)
                    return Long.compare(index, other.index);
                return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
            }
            public String toString() {
                return "[u=" + u + ", v=" + v + "]";
            }
        }
/*****************************************DEBUG***********************************************************/
    public static void debug(Object... o){
        System.out.println(Arrays.deepToString(o));
    }
/************************************MODULAR EXPONENTIATION***********************************************/
    static long modulo(long a,long b,long c){
        long x=1;
        long y=a%c;
        while(b > 0){
            if(b%2 == 1)
                x=(x*y)%c;
            y = (y*y)%c;
            b /= 2;
        }
        return  x%c;
    }
/********************************************GCD**********************************************************/
    static long gcd(long x, long y){
        if(x==0)
            return y;
        if(y==0)
            return x;
        long r=0, a, b;
        a = (x > y) ? x : y;
        b = (x < y) ? x : y;
        r = b;
        while(a % b != 0){
            r = a % b;
            a = b;
            b = r;
        }
        return r;
    }
/********************************************End***********************************************************/
}

import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.StringTokenizer;
import java.util.*;

public class Solution {
    private static final long mod = 998244353;
    static short dp[][];
    static HashMap<Integer,ArrayList<Integer>> map ;
    static HashMap<Integer,String> hm;
    static int n;

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

        FastScanner sc = new FastScanner();

        int t;
        t = 1;//sc.nextInt();
        PrintWriter out = new PrintWriter(System.out);

        while (t-- > 0) {
            solve(sc, out);
        }
        out.close();

    }

    public static void solve(FastScanner sc, PrintWriter out) {
        long n = sc.nextInt();
        long m = sc.nextLong();
        long l = sc.nextInt();
        long r = sc.nextInt();

        long ans = 0;
        long k = r - l + 1;
        ans = pow(k,n*m,mod );

        if(n*m % 2 == 0){
            if(k % 2 != 0)
                ans = (ans + 1)%mod;
         ans = ((ans *  (mod + 1))/2)%mod;
           // ans = ans / 2;
        }

        out.println(ans);
    }

    public static long pow(long a, long n, long mod){
        if(n == 0) return 1;
        else if(n%2 == 0){
            return pow((a*a)%mod,n/2,mod)%mod;
        }
        else return (pow((a*a)%mod,n/2,mod)%mod * a)%mod;
    }

    public static long modInverseCoPrime(long n, long mod){
        return pow(n,mod-2,mod);
    }

    static long modInverse(long A, long M)
    {
        extendedEuclid(A,M);
        return (x%M+M)%M;    //x may be negative
    }

    static long d, x, y;
    static void extendedEuclid(long A, long B) {
        if(B == 0) {
            d = A;
            x = 1;
            y = 0;
        }
        else {
            extendedEuclid(B, A%B);
            long temp = x;
            x = y;
            y = temp - (A/B)*y;
        }
    }

    public static boolean recurse(ArrayList<Integer> ans, int i, int k, ArrayList<String> in){
    if (i == n) {
      if (k == 0) return true;
      return false;
          }
        if(k < 0) return false;

        if(dp[i][k] != 0) return dp[i][k] == 1? true: false;

        int valid = -1;
        String input = in.get(i);
        ArrayList<Pair> p = getNumbers(input);
        boolean check = false;
        for(Pair element : p){
            if(recurse(ans,i+1,k-element.y,in)){
                valid = Math.max(valid, element.x);
                check = true;
                break;
            }
        }

        if(check){ dp[i][k] = 1;ans.add(valid);}
        else dp[i][k] = 2;
        return check;

    }

    public static ArrayList<Pair> getNumbers(String a){
        ArrayList<Pair> ans = new ArrayList<>();

        for (int i = 9; i >=0; i--) {
            int count = 0;
            boolean check = true;
            String b = hm.get(i);
            for (int j = 0; j < a.length(); j++) {
                if (a.charAt(j) == '1' && b.charAt(j) != '1') {check = false; break;}
                if (a.charAt(j) == '0' && b.charAt(j) == '1') count++;
            }

        if (check)
            ans.add(Pair.of(i,count));

        }

        return ans;
    }

    public static  <T> void clear(HashMap<Integer,ArrayList<T>> hm){
        for(int key : hm.keySet())
            hm.put(key, new ArrayList<>());
    }

    public static  <T> void fill(HashMap<Integer,ArrayList<T>> hm, int m){
        for(int i = 1;i<=m;i++)
            hm.put(i, new ArrayList<>());
    }

    static long calcChanges(long[] a, long val, int n, long k){
        long ans = 0;
        for(int i = 1;i<=n/2;i++){
            long x = a[i];
            long y = a[n-i-1];
            if((k + x < val && k + y < val) || ( 1 + x > val && 1 + y > val)){
                ans = ans + 2;
            } else if(x + y != val) ans = ans + 1;
        }
        return ans;
    }

    public static class Pair{
        int x;

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Pair)) return false;
            Pair pair = (Pair) o;
            return x == pair.x &&
                    y == pair.y;
        }

        @Override
        public int hashCode() {
            return Objects.hash(x, y);
        }

        int y;
        public static Pair of(int x, int y){
            Pair p = new Pair();
            p.x = x;
            p.y = y;
            return p;
        }
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

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

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

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}

class DFS{

    public void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        Graph g = new Graph();
        for(int i = 1;i<=n;i++)
            g.addNode(i);

        int e = sc.nextInt();
        while(e-->0){
            int one = sc.nextInt();
            int two = sc.nextInt();
            g.addEdge(one, two);
            g.addEdge(two, one);
        }
        g.resetVisited();
        g.DFS(g.nodes.get(1));

    }
}

class Node{
    int label;
    long touristP;
    long sum;
    Node parent;
    boolean visited = false;
    Node(int l){
        label=l;
        sum = 0;
        touristP = 0;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Node)) return false;
        Node node = (Node) o;
        return label == node.label &&
                touristP == node.touristP &&
                sum == node.sum &&
                visited == node.visited;
    }

    @Override
    public int hashCode() {
        return Objects.hash(label);
    }
}

class Graph{

    HashMap<Node,ArrayList<Node>> hm = new HashMap<>();
    HashMap<Integer,Node> nodes = new HashMap<>();
    Graph(){

    }

    void addNode(int n){
        Node node= new Node(n);
        this.nodes.put(n,node);
    }

    void addEdge(int f,int t){
        Node from = nodes.get(f);
        Node to = nodes.get(t);
        if(!hm.containsKey(from))
            hm.put(from,new ArrayList<>());

        hm.get(from).add(to);
    }

    void resetVisited(){
        for(Node n : hm.keySet()){
            n.visited = false;
            for(Node nn:hm.get(n))
                nn.visited = false;
        }
    }

    void DFS(Node n){
        if(n.visited)
            return;

        n.visited = true;
        System.out.print(n.label + " ");
        if(hm.containsKey(n))
            for(Node an : hm.get(n))
                DFS(an);
    }

    long DFSSum(Node n){
        if(n.visited)
            return 0l;

        n.visited = true;
        if(hm.containsKey(n)) {
            for (Node an : hm.get(n)) {
                n.sum = n.sum + DFSSum(an);

            }
        }

        return n.sum+1;
    }

    void BFS(Node n){
        Queue<Node> q = new LinkedList<>();
        q.add(n);

        while(!q.isEmpty()){
            Node node = q.poll();

            System.out.print(node.label+" ");
            node.visited = true;

            if(!hm.containsKey(node))
                continue;

            for(Node nn: hm.get(node)){
                if(nn.visited == false)
                {
                    if(!nn.visited)
                        q.add(nn);
                }
            }
        }

    }
}

import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.StringTokenizer;
import java.util.*;

public class Solution {
    private static final long mod = 998244353;
    static short dp[][];
    static HashMap<Integer,ArrayList<Integer>> map ;
    static HashMap<Integer,String> hm;
    static int n;

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

        FastScanner sc = new FastScanner();

        int t;
        t = 1;//sc.nextInt();
        PrintWriter out = new PrintWriter(System.out);

        while (t-- > 0) {
            solve(sc, out);
        }
        out.close();

    }

    public static void solve(FastScanner sc, PrintWriter out) {
        long n = sc.nextInt();
        long m = sc.nextLong();
        long l = sc.nextInt();
        long r = sc.nextInt();

        long ans = 0;
        long k = r - l + 1;
        ans = pow(k,n*m,mod );

        if(n*m % 2 == 0){
            if(k % 2 != 0)
                ans = (ans + 1)%mod;
         ans = (ans *  modInverse(2,mod))%mod;
           // ans = ans / 2;
        }

        out.println(ans);
    }

    public static long pow(long a, long n, long mod){
        if(n == 0) return 1;
        else if(n%2 == 0){
            return pow((a*a)%mod,n/2,mod)%mod;
        }
        else return (pow((a*a)%mod,n/2,mod)%mod * a)%mod;
    }

    public static long modInverseCoPrime(long n, long mod){
        return pow(n,mod-2,mod);
    }

    static long modInverse(long A, long M)
    {
        extendedEuclid(A,M);
        return (x%M+M)%M;    //x may be negative
    }

    static long d, x, y;
    static void extendedEuclid(long A, long B) {
        if(B == 0) {
            d = A;
            x = 1;
            y = 0;
        }
        else {
            extendedEuclid(B, A%B);
            long temp = x;
            x = y;
            y = temp - (A/B)*y;
        }
    }

    public static boolean recurse(ArrayList<Integer> ans, int i, int k, ArrayList<String> in){
    if (i == n) {
      if (k == 0) return true;
      return false;
          }
        if(k < 0) return false;

        if(dp[i][k] != 0) return dp[i][k] == 1? true: false;

        int valid = -1;
        String input = in.get(i);
        ArrayList<Pair> p = getNumbers(input);
        boolean check = false;
        for(Pair element : p){
            if(recurse(ans,i+1,k-element.y,in)){
                valid = Math.max(valid, element.x);
                check = true;
                break;
            }
        }

        if(check){ dp[i][k] = 1;ans.add(valid);}
        else dp[i][k] = 2;
        return check;

    }

    public static ArrayList<Pair> getNumbers(String a){
        ArrayList<Pair> ans = new ArrayList<>();

        for (int i = 9; i >=0; i--) {
            int count = 0;
            boolean check = true;
            String b = hm.get(i);
            for (int j = 0; j < a.length(); j++) {
                if (a.charAt(j) == '1' && b.charAt(j) != '1') {check = false; break;}
                if (a.charAt(j) == '0' && b.charAt(j) == '1') count++;
            }

        if (check)
            ans.add(Pair.of(i,count));

        }

        return ans;
    }

    public static  <T> void clear(HashMap<Integer,ArrayList<T>> hm){
        for(int key : hm.keySet())
            hm.put(key, new ArrayList<>());
    }

    public static  <T> void fill(HashMap<Integer,ArrayList<T>> hm, int m){
        for(int i = 1;i<=m;i++)
            hm.put(i, new ArrayList<>());
    }

    static long calcChanges(long[] a, long val, int n, long k){
        long ans = 0;
        for(int i = 1;i<=n/2;i++){
            long x = a[i];
            long y = a[n-i-1];
            if((k + x < val && k + y < val) || ( 1 + x > val && 1 + y > val)){
                ans = ans + 2;
            } else if(x + y != val) ans = ans + 1;
        }
        return ans;
    }

    public static class Pair{
        int x;

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Pair)) return false;
            Pair pair = (Pair) o;
            return x == pair.x &&
                    y == pair.y;
        }

        @Override
        public int hashCode() {
            return Objects.hash(x, y);
        }

        int y;
        public static Pair of(int x, int y){
            Pair p = new Pair();
            p.x = x;
            p.y = y;
            return p;
        }
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

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

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

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}

class DFS{

    public void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        Graph g = new Graph();
        for(int i = 1;i<=n;i++)
            g.addNode(i);

        int e = sc.nextInt();
        while(e-->0){
            int one = sc.nextInt();
            int two = sc.nextInt();
            g.addEdge(one, two);
            g.addEdge(two, one);
        }
        g.resetVisited();
        g.DFS(g.nodes.get(1));

    }
}

class Node{
    int label;
    long touristP;
    long sum;
    Node parent;
    boolean visited = false;
    Node(int l){
        label=l;
        sum = 0;
        touristP = 0;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Node)) return false;
        Node node = (Node) o;
        return label == node.label &&
                touristP == node.touristP &&
                sum == node.sum &&
                visited == node.visited;
    }

    @Override
    public int hashCode() {
        return Objects.hash(label);
    }
}

class Graph{

    HashMap<Node,ArrayList<Node>> hm = new HashMap<>();
    HashMap<Integer,Node> nodes = new HashMap<>();
    Graph(){

    }

    void addNode(int n){
        Node node= new Node(n);
        this.nodes.put(n,node);
    }

    void addEdge(int f,int t){
        Node from = nodes.get(f);
        Node to = nodes.get(t);
        if(!hm.containsKey(from))
            hm.put(from,new ArrayList<>());

        hm.get(from).add(to);
    }

    void resetVisited(){
        for(Node n : hm.keySet()){
            n.visited = false;
            for(Node nn:hm.get(n))
                nn.visited = false;
        }
    }

    void DFS(Node n){
        if(n.visited)
            return;

        n.visited = true;
        System.out.print(n.label + " ");
        if(hm.containsKey(n))
            for(Node an : hm.get(n))
                DFS(an);
    }

    long DFSSum(Node n){
        if(n.visited)
            return 0l;

        n.visited = true;
        if(hm.containsKey(n)) {
            for (Node an : hm.get(n)) {
                n.sum = n.sum + DFSSum(an);

            }
        }

        return n.sum+1;
    }

    void BFS(Node n){
        Queue<Node> q = new LinkedList<>();
        q.add(n);

        while(!q.isEmpty()){
            Node node = q.poll();

            System.out.print(node.label+" ");
            node.visited = true;

            if(!hm.containsKey(node))
                continue;

            for(Node nn: hm.get(node)){
                if(nn.visited == false)
                {
                    if(!nn.visited)
                        q.add(nn);
                }
            }
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class EHeightAllTheSame {
        long mod = 998244353;
        long[][] d;

        long modExp(long x, long y) {
            if (y == 0)
                return 1 % mod;
            long ret = modExp(x, y >> 1);
            ret = ret * ret % mod;
            if ((y & 1) == 1)
                ret = ret * (x % mod) % mod;
            return ret;
        }

        long[][] multiply(long[][] a, long[][] b) {
            long[][] c = new long[2][2];
            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < 2; j++)
                    for (int k = 0; k < 2; k++)
                        c[i][j] = (c[i][j] + a[i][k] * b[k][j] % mod) % mod;
            }
            return c;
        }

        long[][] matExp(long[][] a, long y) {
            if (y == 1)
                return a;
            long[][] ret = matExp(a, y / 2);
            ret = multiply(ret, ret);
            if ((y & 1) == 1)
                ret = multiply(ret, d);
            return ret;
        }

        long value(long y, long p0, long p1) {
            long same = (p0 * p0 % mod + p1 * p1 % mod) % mod;
            long diff = 2 * p0 * p1 % mod;
            d = new long[][]{{same, diff}, {diff, same}};
            long[][] mat = matExp(d, y / 2);
        /*
        for(int i = 0; i < 2; i++) {
            for(int j = 0; j < 2; j++)
                System.out.print(mat[i][j] + " ");
            System.out.println();
        }
        */
            return mat[0][0];
        }

        public void solve(int testNumber, InputReader s, PrintWriter w) {
            long mod = 998244353;
            long n = s.nextLong(), m = s.nextLong(), l = s.nextLong(), r = s.nextLong();
            if ((n * m) % 2 == 1) {
                w.println(modExp(r - l + 1, n * m));
                return;
            }
            long p0 = (r - l + 1) / 2;
            long p1 = (r - l + 1 + 1) / 2;
            w.println(value(n * m, p0, p1));
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long M = Long.parseLong(st.nextToken());
         long L = Long.parseLong(st.nextToken());
         long R = Long.parseLong(st.nextToken());
         //dont panic
         //that makes you lose Omkar energy
         if((N*M)%2 == 1)
         {
            //here?
            long temp = N*M;
            BigInteger exp = new BigInteger(temp+"");
            BigInteger base = new BigInteger((R-L+1)+"");
            BigInteger mod = new BigInteger(MOD+"");
            long res = base.modPow(exp, mod).longValue();
            System.out.println((res+MOD)%MOD);
         }
         else
         {
            long temp = N*M;
            BigInteger exp = new BigInteger(temp+"");
            BigInteger base = new BigInteger((R-L+1)+"");
            BigInteger mod = new BigInteger(MOD+"");
            long res = base.modPow(exp, mod).longValue();
            //res = (res*power(2,MOD-2,MOD))%MOD;
            if((R-L)%2 == 0)
               res++;
            res = (res*power(2,MOD-2,MOD))%MOD;
            System.out.println(res);
         }
      }
      public static long power(long x, long y, long p)
      {
          long res = 1L;
          x = x % p;
          while (y > 0)
          {
              if((y & 1)==1)
                  res = (res * x) % p;
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
   }

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E2
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long M = Long.parseLong(st.nextToken());
         long L = Long.parseLong(st.nextToken());
         long R = Long.parseLong(st.nextToken());
         //fuck Bob
         if((N*M)%2 == 1)
         {
            for(int i=0; i < 100000000; i++);
            long temp = N*M;
            BigInteger exp = new BigInteger(temp+"");
            BigInteger base = new BigInteger((R-L+1)+"");
            BigInteger mod = new BigInteger(MOD+"");
            long res = base.modPow(exp, mod).longValue();
            System.out.println((res+MOD)%MOD);
         }
         else
         {
            //even # of odd columns
            long col = (N*M);

            long odd = (R-L)/2;
            if(R%2 != 0 || L%2 != 0)
               odd++;
            long even = R-L+1-odd;
            odd %= MOD;
            even %= MOD;
            odd = (odd*odd)%MOD;
            even = (even*even)%MOD;

            //find exp
            col /= 2;
            BigInteger exp = new BigInteger(col+"");
            //exp.multiply(new BigInteger(power(2,MOD-2,MOD)+""));

            long temp = (odd+even)%MOD;
            BigInteger base = new BigInteger(temp+"");
            BigInteger mod = new BigInteger(MOD+"");

            BigInteger res = base.modPow(exp, mod);
            System.out.println((res.longValue()+MOD)%MOD);
         }
      }
      public static long power(long x, long y, long p)
      {
          long res = 1L;
          x = x % p;
          while (y > 0)
          {
              if((y & 1)==1)
                  res = (res * x) % p;
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
   }

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E2
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long M = Long.parseLong(st.nextToken());
         long L = Long.parseLong(st.nextToken());
         long R = Long.parseLong(st.nextToken());
         //fuck Bob
         if((N*M)%2 == 1)
         {
            long temp = N*M;
            //temp %= MOD;
            long res = power(R-L+1, temp, MOD);
            System.out.println(res);
         }
         else
         {
            //even # of odd columns
            long col = (N*M);
            long odd = R/2;
            if(R%2 == 1)
               odd++;
            odd -= (L-1)/2;
            if((L-1)%2 == 1)
               odd--;
            long even = R-L+1-odd;
            odd %= MOD;
            even %= MOD;
            odd = (odd*odd)%MOD;
            even = (even*even)%MOD;
            //find exp
            col /= 2;
            BigInteger exp = new BigInteger(col+"");
            //exp.multiply(new BigInteger(power(2,MOD-2,MOD)+""));

            long temp = (odd+even)%MOD;
            BigInteger base = new BigInteger(temp+"");
            BigInteger mod = new BigInteger(MOD+"");

            BigInteger res = base.modPow(exp, mod);
            System.out.println(res.longValue());
         }
      }
      public static long power(long x, long y, long p)
      {
          long res = 1L;
          x = x % p;
          while (y > 0)
          {
              if((y & 1)==1)
                  res = (res * x) % p;
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
   }

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E2
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long M = Long.parseLong(st.nextToken());
         long L = Long.parseLong(st.nextToken());
         long R = Long.parseLong(st.nextToken());
         if((N*M)%2 == 1)
         {
            //here?
            long temp = N*M;
            BigInteger exp = new BigInteger(temp+"");
            BigInteger base = new BigInteger((R-L+1)+"");
            BigInteger mod = new BigInteger(MOD+"");
            long res = base.modPow(exp, mod).longValue();
            if((N*M)%4 == 0)
            res = (res*power(2, MOD-2,MOD))%MOD;
            System.out.println((res+MOD)%MOD);
         }
         else
         {
            //even # of odd columns
            long col = (N*M);

            long odd = (R-L)/2;
            if(R%2 != 0 || L%2 != 0)
               odd++;
            long even = R-L+1-odd;
            odd = (odd*odd)%MOD;
            even = (even*even)%MOD;

            //find exp
            col /= 2;
            BigInteger exp = new BigInteger(col+"");
            //exp.multiply(new BigInteger(power(2,MOD-2,MOD)+""));

            long temp = (odd+even)%MOD;
            BigInteger base = new BigInteger(temp+"");
            BigInteger mod = new BigInteger(MOD+"");

            BigInteger res = base.modPow(exp, mod);
            System.out.println((res.longValue()+MOD)%MOD);
         }
      }
      public static long power(long x, long y, long p)
      {
          long res = 1L;
          x = x % p;
          while (y > 0)
          {
              if((y & 1)==1)
                  res = (res * x) % p;
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
   }

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EHeightAllTheSame solver = new EHeightAllTheSame();
        solver.solve(1, in, out);
        out.close();
    }

    static class EHeightAllTheSame {
        long mod = 998244353;

        long countOdd(long L, long R) {
            long N = (R - L) / 2;
            if (R % 2 != 0 || L % 2 != 0)
                N += 1;
            return N;
        }

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            long n = in.scanInt();
            long m = in.scanInt();
            long l = in.scanInt();
            long r = in.scanInt();
            long prod = (n * m);
            long ct_odd = countOdd(l, r);
            long ct_even = r - l + 1 - ct_odd;
            if (ct_odd == 0) {
                out.println(CodeHash.pow(ct_even, prod, mod));
                return;
            } else if (ct_even == 0) {
                out.println(CodeHash.pow(ct_odd, prod, mod));
                return;
            }
            if (prod % 2 == 0) {
                long ans = (CodeHash.pow((ct_even - ct_odd + mod) % mod, prod, mod) + CodeHash.pow((ct_even + ct_odd) % mod, prod, mod)) % mod;
                ans = (ans * CodeHash.modInverse(2, mod)) % mod;
                out.println(ans);
            } else {
                long ans = (-CodeHash.pow((ct_even - ct_odd + mod) % mod, prod, mod) + CodeHash.pow((ct_even + ct_odd) % mod, prod, mod) + mod) % mod;
                out.println(ans);
            }
        }

    }

    static class CodeHash {
        public static long[] euclidExtended(long a, long b) {
            if (b == 0) {
                long ar[] = new long[]{1, 0};
                return ar;
            }
            long ar[] = euclidExtended(b, a % b);
            long temp = ar[0];
            ar[0] = ar[1];
            ar[1] = temp - (a / b) * ar[1];
            return ar;
        }

        public static long modInverse(long a, long m) {
            long ar[] = euclidExtended(a, m);
            return ((ar[0] % m) + m) % m;
        }

        public static long pow(long a, long b, long m) {
            long res = 1;
            a %= m;
            while (b > 0) {
                if ((b & 1) == 1) res = (res * a) % m;
                a = (a * a) % m;
                b >>= 1;
            }
            return res;
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EHeightAllTheSame solver = new EHeightAllTheSame();
        solver.solve(1, in, out);
        out.close();
    }

    static class EHeightAllTheSame {
        long mod = 998244353;

        long countOdd(long L, long R) {
            long N = (R - L) / 2;
            if (R % 2 != 0 || L % 2 != 0)
                N += 1;
            return N;
        }

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            long n = in.scanInt();
            long m = in.scanInt();
            long l = in.scanInt();
            long r = in.scanInt();
            long prod = (n * m);
            long ct_odd = countOdd(l, r);
            long ct_even = r - l + 1 - ct_odd;
            if (prod % 2 == 0) {
                long ans = (CodeHash.pow((ct_even - ct_odd + mod) % mod, prod, mod) + CodeHash.pow((ct_even + ct_odd) % mod, prod, mod)) % mod;
                ans = (ans * CodeHash.modInverse(2, mod)) % mod;
                out.println(ans);
            } else {
                long ans = (-CodeHash.pow((ct_even - ct_odd + mod) % mod, prod, mod) + CodeHash.pow((ct_even + ct_odd) % mod, prod, mod) + mod) % mod;
                out.println(ans);
            }
        }

    }

    static class CodeHash {
        public static long[] euclidExtended(long a, long b) {
            if (b == 0) {
                long ar[] = new long[]{1, 0};
                return ar;
            }
            long ar[] = euclidExtended(b, a % b);
            long temp = ar[0];
            ar[0] = ar[1];
            ar[1] = temp - (a / b) * ar[1];
            return ar;
        }

        public static long modInverse(long a, long m) {
            long ar[] = euclidExtended(a, m);
            return ((ar[0] % m) + m) % m;
        }

        public static long pow(long a, long b, long m) {
            long res = 1;
            a %= m;
            while (b > 0) {
                if ((b & 1) == 1) res = (res * a) % m;
                a = (a * a) % m;
                b >>= 1;
            }
            return res;
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}

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

/**
 * Created by Katushka on 11.03.2020.
 */
public class B {
    static int[] readArray(int size, InputReader in) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = in.nextInt();
        }
        return a;
    }

    static long[] readLongArray(int size, InputReader in) {
        long[] a = new long[size];
        for (int i = 0; i < size; i++) {
            a[i] = in.nextLong();
        }
        return a;
    }

    final static long MOD = 998244353;

    private static long fastPow(long x, long y) {
        if (x == 1) {
            return 1;
        }
        if (y == 0) {
            return 1;
        }
        long p = fastPow(x,y / 2) % MOD;
        p = p * p % MOD;
        if (y % 2 == 1) {
            p = p * x % MOD;
        }
        return p;
    }

    public static void main(String[] args) throws FileNotFoundException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        long n = in.nextInt();
        long m = in.nextInt();
        long l = in.nextInt();
        long r = in.nextInt();
        if (n % 2 != 0 && m % 2 != 0) {
            out.println(fastPow((r - l + 1), n * m));
        } else {
            long res1 =  fastPow((r - l + 1), n * m - 1);
            long res;
            if ((r - l + 1) % 2 == 0) {
                res = res1 * ((r - l + 1) / 2)  % MOD;
            } else {
                res = (res1 * ((r - l + 2) / 2) - res1 / 2) % MOD;
            }
            out.println(res);
        }

        out.close();
    }

    private static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public String nextString() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

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

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

        public char nextChar() {
            return next().charAt(0);
        }
    }
}

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

/**
 * Created by Katushka on 11.03.2020.
 */
public class B {
    static int[] readArray(int size, InputReader in) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = in.nextInt();
        }
        return a;
    }

    static long[] readLongArray(int size, InputReader in) {
        long[] a = new long[size];
        for (int i = 0; i < size; i++) {
            a[i] = in.nextLong();
        }
        return a;
    }

    final static long MOD = 998244353;

    private static long fastPow(long x, long y) {
        if (y == 0) {
            return 1;
        }
        long p = fastPow(x,y / 2) % MOD;
        p = p * p % MOD;
        if (y % 2 == 1) {
            p = p * x % MOD;
        }
        return p;
    }

    public static void main(String[] args) throws FileNotFoundException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        long n = in.nextInt();
        long m = in.nextInt();
        long l = in.nextInt();
        long r = in.nextInt();
        if (n % 2 != 0 && m % 2 != 0) {
            out.println(fastPow((r - l + 1), n * m));
        } else {
            long res1 =  fastPow((r - l + 1), n * m - 1);
            long res = 0;
            if ((r - l + 1) % 2 == 0) {
                res = res1 * ((r - l + 1) / 2)  % MOD;
            } else {
                res = (res1 * ((r - l + 2) / 2) - (r - l) / 2) % MOD;
            }
            out.println(res);
        }

        out.close();
    }

    private static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public String nextString() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

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

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

        public char nextChar() {
            return next().charAt(0);
        }
    }
}

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

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }

    long mod=998244353;

    void solve() throws IOException {
        long n=nl(),m=nl(),a=nl(),b=nl();
        long t=n*m;
        if (t%2==1) {
            out.println(mp(b-a+1,t));
        }
        else {
            long ans=mp(b-a+1,t);
            if (b-a+1%2==1) ans=(ans+1)%mod;
            ans=(ans*mp(2,mod-2))%mod;
            out.println(ans);
        }
        out.flush();
    }

    long mp(long a,long p) {
        long r=1;
        while (p>0) {
            if ((p&1)>0) r=(r*a)%mod;
            p=p>>1;
            a=(a*a)%mod;
        }
        return r;
    }

    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

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

public class S{
   static class Pair implements Comparable<Pair>{
   int a;
   int b;
   public Pair(int x,int y){a=x;b=y;}
   public Pair(){}
   public int compareTo(Pair p1){
       if(a == p1.a)
       return b - p1.b;
       return a - p1.a;
   }
 }
static class TrieNode{
  TrieNode[]child;
  int w;
  boolean term;
  TrieNode(){
    child = new TrieNode[26];
  }
}
  public static int gcd(int a,int b)
  {
    if(a<b)
      return gcd(b,a);
    if(b==0)
      return a;
    return gcd(b,a%b);

  }
  //static long ans = 0;
  static long mod =998244353;

    public static void main(String[] args) throws Exception {
       new Thread(null, null, "Anshum Gupta", 99999999) {
            public void run() {
                try {
                    solve();
                } catch(Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }
static long[][]dp;
static int maxV;
static long pow(long x,long y){
    if(y == 0)return 1;
    if(y==1)return x;
    long a = pow(x,y/2);
    if(x%2==0){
        return (a*a)%mod;
    }
    return (((a*a)%mod)*x)%mod;
}
static void dfs
(ArrayList<ArrayList<Integer>>adj,int sv,boolean[]vis,int[]x){}
static TrieNode root;
 public static void solve() throws Exception {
   // solve the problem here
   MyScanner s = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int t = 1;//s.nextInt();
        int tc = 0;
      //  maxV = 300000;
        while(tc++<t){
            int n = s.nextInt();
            int m = s.nextInt();
            int l = s.nextInt();
            int r = s.nextInt();
            int e = (r-l+1)/2;
            int o = r-l+1 - (r-l+1)/2;
            long tt = r-l+1;
            if((n*m)%2==0)
            {
                out.println(pow((long)r-l+1,(long)m*n));
            }
            else{
                long x = (pow(e+o,m*n) - 1)%mod;
                x *= pow(2,mod-2);
                x%=mod;
                long ans = (pow((long)r-l+1,(long)m*n) - x)%mod;
                out.println(ans);
            }
        }
        out.flush();
}

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

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

public class Solution{
	long mod = 998244353L;

	public void solve(int test, Scanner sc){
		long n = sc.nextLong();
		long m = sc.nextLong();
		long l = sc.nextLong();
		long r = sc.nextLong();

		long total = power(r-l+1L, n*m);

		if((n*m)%2 == 1){
			System.out.println(total);
		}
		else{
			total++;
			total%=mod;
			total /= 2L;
			total %= mod;
			System.out.println(total);
		}
	}

	public long power(long a, long b){
		if(b == 0){
			return 1L;
		}

		if(b%2 == 0){
			return power(((a*a)%mod), b/2L);
		}
		else{
			return ((power(((a*a)%mod), b/2L)*a)%mod);
		}
	}

	public long modInverse(long a){
		return power(a, mod-2L);
	}

	public Solution(){
		Scanner sc = new Scanner(System.in);
		int tests = 1;

        for(int t=1; t<=tests; t++){
			solve(t, sc);
        }
	}

	public static void main(String[] args){
		new Solution();
	}
}

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

public class Solution{
	long mod = 998244353L;

	public void solve(int test, Scanner sc){
		long n = sc.nextLong();
		long m = sc.nextLong();
		long l = sc.nextLong();
		long r = sc.nextLong();

		long total = power(r-l+1L, n*m);

		if((n*m)%2 == 1){
			System.out.println(total);
		}
		else{
			total++;
			total%=mod;
			total *= modInverse(2L);
			total %= mod;
			System.out.println(total);
		}
	}

	public long power(long a, long b){
		if(b == 0){
			return 1L;
		}

		if(b%2 == 0){
			return power(((a*a)%mod), b/2L);
		}
		else{
			return ((power(((a*a)%mod), b/2L)*a)%mod);
		}
	}

	public long modInverse(long a){
		return power(a, mod-2L);
	}

	public Solution(){
		Scanner sc = new Scanner(System.in);
		int tests = 1;

        for(int t=1; t<=tests; t++){
			solve(t, sc);
        }
	}

	public static void main(String[] args){
		new Solution();
	}
}

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

public class E {
	public static void main(String[] args) throws Exception {
		new E().run();
	}
	public void run() throws Exception {
		FastScanner f = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = f.nextInt();
		int m = f.nextInt();
		int l = f.nextInt();
		int r = f.nextInt();
		int even = r/2-(l+1)/2+1;
		int odd = r-l+1-even;
		int[][] mat = {{even, odd},{odd, even}};
		mat = exp(mat, n);
		mat = exp(mat, m);
		out.println(mat[0][0]);
///
		out.flush();
	}
	public int MOD = 998_244_353;
	public int[][] mult(int[][] a, int[][] b) {
		int[][] c = new int[a.length][b[0].length];
		for(int i = 0; i < a.length; i++)
			for(int j = 0; j < b[0].length; j++)
				for(int k = 0; k < b.length; k++)
					c[i][j] = (c[i][j] + a[i][k] * b[k][j] % MOD) % MOD;
		return c;
	}
	public int[][] exp(int[][] m, int e) {
		if(e == 1) return m;
		int[][] r = exp(m, e >> 1);
		r = mult(r, r);
		if(e%2 == 1)
			r = mult(r, m);
		return r;
	}
///
    static class FastScanner {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public FastScanner() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
        public String nextLine() {
        	try {
        		return reader.readLine();
        	} catch(IOException e) {
        		throw new RuntimeException(e);
        	}
        }
    }
}

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

public class E {
	public static void main(String[] args) throws Exception {
		new E().run();
	}
	public void run() throws Exception {
		FastScanner f = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = f.nextInt();
		int m = f.nextInt();
		int l = f.nextInt();
		int r = f.nextInt();
		int even = r/2-(l+1)/2+1;
		int odd = r-l+1-even;
		long[][] mat = {{even, odd},{odd, even}};
		mat = exp(mat, n);
		mat = exp(mat, m);
		out.println(mat[0][0]);
///
		out.flush();
	}
	public int MOD = 998_244_353;
	public long[][] mult(long[][] a, long[][] b) {
		long[][] c = new long[a.length][b[0].length];
		for(int i = 0; i < a.length; i++)
			for(int j = 0; j < b[0].length; j++)
				for(int k = 0; k < b.length; k++)
					c[i][j] = (c[i][j] + a[i][k] * b[k][j] % MOD) % MOD;
		return c;
	}
	public long[][] exp(long[][] m, int e) {
		if(e == 1) return m;
		long[][] r = exp(m, e >> 1);
		r = mult(r, r);
		if(e%2 == 1)
			r = mult(r, m);
		return r;
	}
///
    static class FastScanner {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public FastScanner() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
        public String nextLine() {
        	try {
        		return reader.readLine();
        	} catch(IOException e) {
        		throw new RuntimeException(e);
        	}
        }
    }
}

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

public class CF1332E extends PrintWriter {
	CF1332E() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1332E o = new CF1332E(); o.main(); o.flush();
	}

	static final int MD = 998244353;
	long power(int a, int k) {
		if (k == 0)
			return 1;
		long p = power(a, k / 2);
		p = p * p % MD;
		if (k % 2 == 1)
			p = p * a % MD;
		return p;
	}
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int r = sc.nextInt();
		if (l == r) {
			println(1);
			return;
		}
		long k = r - l + 1;
		long c = (long) n * m;
		long ans = power((int) (k % MD), (int) (c % (MD - 1)));
		if (n % 2 == 0 || m % 2 == 0) {
			if (k % 2 == 0) {
				int inv2 = (MD + 1) / 2;
				ans = ans * inv2 % MD;
			} else {
				long a = k / 2, b = k - a;
				a = (long) a * a;
				b = (long) b * b;
				k = a + b;
				c /= 2;
				ans = power((int) (k % MD), (int) (c % (MD - 1)));
			}
		}
		println(ans);
	}
}

import java.io.*;
import java.util.*;
public class Main{
	static int mod=998244353;
	static long fastpow(long n,long ti) {
		 if (ti == 0)
		        return 1l;
		if(ti%2==0) {
			long y=fastpow(n, ti/2);
			long k=y*y;
			k%=mod;
			return k;
		}
		else {
			long y=fastpow(n, ti/2);
			long k=((n*y)%mod)*y;
			k%=mod;
			return k;
		}
	}
	static long modInv(long x) {
		return fastpow(x, mod-2);
	}
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		long n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt(),r=sc.nextInt();
		if(l==r) {
			pw.println(1);
			pw.flush();
			return;
		}

		long odds=((r+1)/2)-(l/2),evens=(r/2)-((l-1)/2);

		if((n*m)%2==1) {
			long ans=fastpow(odds+evens, (n*m));
			pw.println(ans);
		}
		else {
			long ans=fastpow(odds+evens, (n*m));
			ans=(ans*modInv(2))%mod;

			pw.println(ans);
		}

		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}

import java.io.*;
import java.util.*;
public class Main{
	static int mod=998244353;
	static long fastpow(long n,long ti) {
		 if (ti == 0)
		        return 1l;
		if(ti%2==0) {
			long y=fastpow(n, ti/2);
			long k=y*y;
			k%=mod;
			return k;
		}
		else {
			long y=fastpow(n, ti/2);
			long k=((n*y)%mod)*y;
			k%=mod;
			return k;
		}
	}
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		long n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt(),r=sc.nextInt();
		if(l==r) {
			pw.println(1);
			pw.flush();
			return;
		}

		long odds=((r+1)/2)-(l/2),evens=(r/2)-((l-1)/2);

		long ans=fastpow(odds+evens, (n*m)-1);

		ans=(ans*2)%mod;
//		if((n*m)%2==1) {
//
//		}

		pw.println(ans);

		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}

import java.io.*;
import java.util.*;
public class Main{
	static int mod=998244353;
	static long fastpow(long n,long ti) {
		 if (ti == 0)
		        return 1l;
		if(ti%2==0) {
			long y=fastpow(n, ti/2);
			long k=y*y;
			k%=mod;
			return k;
		}
		else {
			long y=fastpow(n, ti/2);
			long k=((n*y)%mod)*y;
			k%=mod;
			return k;
		}
	}
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		long n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt(),r=sc.nextInt();
		if(l==r) {
			pw.println(1);
			pw.flush();
			return;
		}

		long odds=((r+1)/2)-(l/2),evens=(r/2)-((l-1)/2);

		if((n*m)%2==1) {
			long ans=fastpow(odds+evens, (n*m));
			pw.println(ans);
		}
		else {
			long ans=fastpow(odds+evens, (n*m)-1);
			pw.println(ans);
		}

		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}

import java.io.*;
import java.util.*;
public class Main{
	static int mod=998244353;
	static long fastpow(long n,long ti) {
		 if (ti == 0)
		        return 1l;
		if(ti%2==0) {
			long y=fastpow(n, ti/2);
			long k=y*y;
			k%=mod;
			return k;
		}
		else {
			long y=fastpow(n, ti/2);
			long k=((n*y)%mod)*y;
			k%=mod;
			return k;
		}
	}
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		long n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt(),r=sc.nextInt();
		if(l==r) {
			pw.println(1);
			pw.flush();
			return;
		}

		long odds=((r+1)/2)-(l/2),evens=(r/2)-((l-1)/2);

		long ans=fastpow(odds+evens, (n*m)-1);

//		if((n*m)%2==1) {
//			ans=(ans*2)%mod;
//		}

		pw.println(ans);

		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}

import java.io.*;
import java.util.*;
public class Main{
	static int mod=998244353;
	static long fastpow(long n,long ti) {
		 if (ti == 0)
		        return 1l;
		if(ti%2==0) {
			long y=fastpow(n, ti/2);
			long k=y*y;
			k%=mod;
			return k;
		}
		else {
			long y=fastpow(n, ti/2);
			long k=((n*y)%mod)*y;
			k%=mod;
			return k;
		}
	}
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		long n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt(),r=sc.nextInt();
		if(l==r) {
			pw.println(1);
			pw.flush();
			return;
		}

		long odds=((r+1)/2)-(l/2),evens=(r/2)-((l-1)/2);

		long ans=fastpow(odds+evens, (n*m)-1);

		if((n*m)%2==1) {
			ans=(ans*2)%mod;
		}
		pw.println(ans);

		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}

import java.io.*;
import java.util.*;
public class Main{
	static int mod=998244353;
	static long fastpow(long n,long ti) {
		 if (ti == 0)
		        return 1l;
		if(ti%2==0) {
			long y=fastpow(n, ti/2);
			long k=y*y;
			k%=mod;
			return k;
		}
		else {
			long y=fastpow(n, ti/2);
			long k=((n*y)%mod)*y;
			k%=mod;
			return k;
		}
	}
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		long n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt(),r=sc.nextInt();
		long odds=((r+1)/2)-(l/2),evens=(r/2)-((l-1)/2);

		long ans=fastpow(odds+evens, n*m-1);

		if((n*m)%2==1) {
			ans=(ans*2)%mod;
		}
		pw.println(ans);

		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;

/**
 * @author Nikita Gorokhov <wackloner@yandex-team.ru>
 */
public class E {

    private final static long MOD = 998244353;

    private long powByMod(long n, long p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }
        if (p % 2 == 0) {
            long half = powByMod(n, p / 2);
            return half * half % MOD;
        } else {
            return n * powByMod(n, p - 1) % MOD;
        }
    }

    private void solve() {
        long n = nextInt(), m = nextInt(), L = nextInt(), R = nextInt();

        if (n * m % 2 == 1) {
            long cnt = R - L + 1;
            out.println(powByMod(cnt, n * m));
        } else {
            long cnt = R - L + 1;
            long sum = powByMod(cnt, n * m);
            if (cnt % 2 == 0) {
                out.println(sum);
            } else {
                out.println((sum + 1) % MOD);
            }
        }

    }

    private final static String INPUT_FILENAME = "input.txt";
    private final static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private InputStream inputStream;
    private PrintWriter out;

    private void run() throws FileNotFoundException {
        inputStream = ONLINE_JUDGE ? System.in : new FileInputStream(INPUT_FILENAME);
        out = new PrintWriter(System.out);

        solve();

        out.flush();
    }

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

    private byte[] buffer = new byte[1024];
    private int bufferLen = 0, bufferPtr = 0;

    private int readByte() {
        if (bufferLen == -1) {
            throw new InputMismatchException();
        }
        if (bufferPtr >= bufferLen) {
            bufferPtr = 0;
            try {
                bufferLen = inputStream.read(buffer);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (bufferLen <= 0) {
                return -1;
            }
        }
        return buffer[bufferPtr++];
    }

    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 nextDouble() {
        return Double.parseDouble(next());
    }

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

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

    private int nextInt() {
        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 * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nextLong() {
        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();
        }
    }
}

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;

/**
 * @author Nikita Gorokhov <wackloner@yandex-team.ru>
 */
public class E {

    private final static long MOD = 998244353;

    private long powByMod(long n, long p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }
        if (p % 2 == 0) {
            long half = powByMod(n, p / 2);
            return half * half % MOD;
        } else {
            return n * powByMod(n, p - 1) % MOD;
        }
    }

    private void solve() {
        long n = nextInt(), m = nextInt(), L = nextInt(), R = nextInt();

        if (n * m % 2 == 1) {
            long cnt = R - L + 1;
            out.println(powByMod(cnt, n * m));
        } else {
            long cnt = R - L + 1;
            long sum = powByMod(cnt, n * m);
            if (cnt % 2 == 0) {
                out.println(sum / 2);
            } else {
                out.println((sum + 1) / 2);
            }
        }

    }

    private final static String INPUT_FILENAME = "input.txt";
    private final static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private InputStream inputStream;
    private PrintWriter out;

    private void run() throws FileNotFoundException {
        inputStream = ONLINE_JUDGE ? System.in : new FileInputStream(INPUT_FILENAME);
        out = new PrintWriter(System.out);

        solve();

        out.flush();
    }

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

    private byte[] buffer = new byte[1024];
    private int bufferLen = 0, bufferPtr = 0;

    private int readByte() {
        if (bufferLen == -1) {
            throw new InputMismatchException();
        }
        if (bufferPtr >= bufferLen) {
            bufferPtr = 0;
            try {
                bufferLen = inputStream.read(buffer);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (bufferLen <= 0) {
                return -1;
            }
        }
        return buffer[bufferPtr++];
    }

    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 nextDouble() {
        return Double.parseDouble(next());
    }

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

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

    private int nextInt() {
        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 * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nextLong() {
        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();
        }
    }
}

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;

/**
 * @author Nikita Gorokhov <wackloner@yandex-team.ru>
 */
public class E {

    private final static long MOD = 998244353;

    private long powByMod(long n, long p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }
        if (p % 2 == 0) {
            long half = powByMod(n, p / 2);
            return half * half % MOD;
        } else {
            return n * powByMod(n, p - 1) % MOD;
        }
    }

    private void solve() {
        long n = nextInt(), m = nextInt(), L = nextInt(), R = nextInt();

        if (n * m % 2 == 1) {
            long cnt = R - L + 1;
            out.println(powByMod(cnt, n * m));
        } else {
            long cnt = R - L + 1;
            long sum = powByMod(cnt, n * m);
            if (cnt % 2 == 0) {
                out.println(sum);
            } else {
                out.println(sum);
            }
        }

    }

    private final static String INPUT_FILENAME = "input.txt";
    private final static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private InputStream inputStream;
    private PrintWriter out;

    private void run() throws FileNotFoundException {
        inputStream = ONLINE_JUDGE ? System.in : new FileInputStream(INPUT_FILENAME);
        out = new PrintWriter(System.out);

        solve();

        out.flush();
    }

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

    private byte[] buffer = new byte[1024];
    private int bufferLen = 0, bufferPtr = 0;

    private int readByte() {
        if (bufferLen == -1) {
            throw new InputMismatchException();
        }
        if (bufferPtr >= bufferLen) {
            bufferPtr = 0;
            try {
                bufferLen = inputStream.read(buffer);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (bufferLen <= 0) {
                return -1;
            }
        }
        return buffer[bufferPtr++];
    }

    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 nextDouble() {
        return Double.parseDouble(next());
    }

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

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

    private int nextInt() {
        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 * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nextLong() {
        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();
        }
    }
}

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

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class cf1332e {

    static Map<Long, Integer> f = new HashMap<>(), g = new HashMap<>();

    public static void main(String[] args) throws IOException {
        int n = rni(), m = ni(), l = ni(), r = ni();
        long nm = (long) n * m;
        int N = r - l + 1, E = l % 2 == 0 ? (N + 1) / 2 : N / 2;
        N %= mmod;
        E %= mmod;
        f.put(0L, 1);
        f.put(1L, E);
        g.put(0L, 0);
        g.put(1L, msub(N, E));
        prln(f(nm));
        close();
    }

    static int f(long n) {
        if (f.containsKey(n)) {
            return f.get(n);
        }
        f.put(n, madd(mmul(f(n / 2), f((n + 1) / 2)), mmul(g(n / 2), g((n + 1) / 2))));
        return f.get(n);
    }

    static int g(long n) {
        if (g.containsKey(n)) {
            return g.get(n);
        }
        g.put(n, madd(mmul(f(n / 2), g((n + 1) / 2)), mmul(g(n / 2), f((n + 1) / 2))));
        return g.get(n);
    }

    static int mmod = 998244353;

    static int madd(int a, int b) {
        return (a + b) % mmod;
    }

    static int madd(int... a) {
        int ans = a[0];
        for (int i = 1; i < a.length; ++i) {
            ans = madd(ans, a[i]);
        }
        return ans;
    }

    static int msub(int a, int b) {
        return (a - b + mmod) % mmod;
    }

    static int mmul(int a, int b) {
        return (int) ((long) a * b % mmod);
    }

    static int mmul(int... a) {
        int ans = a[0];
        for (int i = 1; i < a.length; ++i) {
            ans = mmul(ans, a[i]);
        }
        return ans;
    }

    static int minv(int x) {
        return mpow(x, mmod - 2);
    }

    static int mpow(int a, int b) {
        if (a == 0) {
            return 0;
        }
        int ans = 1;
        while (b > 0) {
            if ((b & 1) > 0) {
                ans = mmul(ans, a);
            }
            a = mmul(a, a);
            b >>= 1;
        }
        return ans;
    }

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // references
    // IBIG = 1e9 + 7
    // IMAX ~= 2e9
    // LMAX ~= 9e18

    // constants
    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;
    // math util
    static int minof(int a, int b, int c) {return min(a, min(b, c));}
    static int minof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); int min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static long minof(long a, long b, long c) {return min(a, min(b, c));}
    static long minof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); long min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static int maxof(int a, int b, int c) {return max(a, max(b, c));}
    static int maxof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); int max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static long maxof(long a, long b, long c) {return max(a, max(b, c));}
    static long maxof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); long max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static int powi(int a, int b) {if (a == 0) return 0; int ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static long powl(long a, int b) {if (a == 0) return 0; long ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static int fli(double d) {return (int) d;}
    static int cei(double d) {return (int) ceil(d);}
    static long fll(double d) {return (long) d;}
    static long cel(double d) {return (long) ceil(d);}
    static int gcf(int a, int b) {return b == 0 ? a : gcf(b, a % b);}
    static long gcf(long a, long b) {return b == 0 ? a : gcf(b, a % b);}
    static int lcm(int a, int b) {return a * b / gcf(a, b);}
    static long lcm(long a, long b) {return a * b / gcf(a, b);}
    static int randInt(int min, int max) {return __rand.nextInt(max - min + 1) + min;}
    static long mix(long x) {x += 0x9e3779b97f4a7c15L; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L; x = (x ^ (x >> 27)) * 0x94d049bb133111ebL; return x ^ (x >> 31);}
    // array util
    static void reverse(int[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {int swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(long[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {long swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(double[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {double swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(char[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {char swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void shuffle(int[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); int swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(long[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); long swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(double[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); double swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void rsort(int[] a) {shuffle(a); sort(a);}
    static void rsort(long[] a) {shuffle(a); sort(a);}
    static void rsort(double[] a) {shuffle(a); sort(a);}
    static int[] copy(int[] a) {int[] ans = new int[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static long[] copy(long[] a) {long[] ans = new long[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static double[] copy(double[] a) {double[] ans = new double[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static char[] copy(char[] a) {char[] ans = new char[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    // graph util
    static List<List<Integer>> g(int n) {List<List<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; ++i) g.add(new ArrayList<>()); return g;}
    static List<Set<Integer>> sg(int n) {List<Set<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; ++i) g.add(new HashSet<>()); return g;}
    static void c(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v); g.get(v).add(u);}
    static void cto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v);}
    static void dc(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v); g.get(v).remove(u);}
    static void dcto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v);}
    // input
    static void r() throws IOException {input = new StringTokenizer(rline());}
    static int ri() throws IOException {return Integer.parseInt(rline());}
    static long rl() throws IOException {return Long.parseLong(rline());}
    static double rd() throws IOException {return Double.parseDouble(rline());}
    static int[] ria(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni(); return a;}
    static int[] riam1(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni() - 1; return a;}
    static long[] rla(int n) throws IOException {long[] a = new long[n]; r(); for (int i = 0; i < n; ++i) a[i] = nl(); return a;}
    static double[] rda(int n) throws IOException {double[] a = new double[n]; r(); for (int i = 0; i < n; ++i) a[i] = nd(); return a;}
    static char[] rcha() throws IOException {return rline().toCharArray();}
    static String rline() throws IOException {return __in.readLine();}
    static String n() {return input.nextToken();}
    static int rni() throws IOException {r(); return ni();}
    static int ni() {return Integer.parseInt(n());}
    static long rnl() throws IOException {r(); return nl();}
    static long nl() {return Long.parseLong(n());}
    static double rnd() throws IOException {r(); return nd();}
    static double nd() {return Double.parseDouble(n());}
    static List<List<Integer>> rg(int n, int m) throws IOException {List<List<Integer>> g = g(n); for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1); return g;}
    static void rg(List<List<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1);}
    static List<List<Integer>> rdg(int n, int m) throws IOException {List<List<Integer>> g = g(n); for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1); return g;}
    static void rdg(List<List<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1);}
    static List<Set<Integer>> rsg(int n, int m) throws IOException {List<Set<Integer>> g = sg(n); for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1); return g;}
    static void rsg(List<Set<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1);}
    static List<Set<Integer>> rdsg(int n, int m) throws IOException {List<Set<Integer>> g = sg(n); for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1); return g;}
    static void rdsg(List<Set<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1);}
    // output
    static void pr(int i) {__out.print(i);}
    static void prln(int i) {__out.println(i);}
    static void pr(long l) {__out.print(l);}
    static void prln(long l) {__out.println(l);}
    static void pr(double d) {__out.print(d);}
    static void prln(double d) {__out.println(d);}
    static void pr(char c) {__out.print(c);}
    static void prln(char c) {__out.println(c);}
    static void pr(char[] s) {__out.print(new String(s));}
    static void prln(char[] s) {__out.println(new String(s));}
    static void pr(String s) {__out.print(s);}
    static void prln(String s) {__out.println(s);}
    static void pr(Object o) {__out.print(o);}
    static void prln(Object o) {__out.println(o);}
    static void prln() {__out.println();}
    static void pryes() {prln("yes");}
    static void pry() {prln("Yes");}
    static void prY() {prln("YES");}
    static void prno() {prln("no");}
    static void prn() {prln("No");}
    static void prN() {prln("NO");}
    static void pryesno(boolean b) {prln(b ? "yes" : "no");};
    static void pryn(boolean b) {prln(b ? "Yes" : "No");}
    static void prYN(boolean b) {prln(b ? "YES" : "NO");}
    static void prln(int... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(long... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(double... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static <T> void prln(Collection<T> c) {int n = c.size() - 1; Iterator<T> iter = c.iterator(); for (int i = 0; i < n; pr(iter.next()), pr(' '), ++i); if (n >= 0) prln(iter.next()); else prln();}
    static void h() {prln("hlfd"); flush();}
    static void flush() {__out.flush();}
    static void close() {__out.close();}}

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

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class cf1332e {

    static Map<Long, Integer> f = new HashMap<>(), g = new HashMap<>();

    public static void main(String[] args) throws IOException {
        int n = rni(), m = ni(), l = ni(), r = ni();
        long nm = (long) n * m;
        int N = r - l + 1, E = l % 2 == 0 ? (N + 1) / 2 : N / 2;
        f.put(0L, 1);
        f.put(1L, E % mmod);
        g.put(0L, 0);
        g.put(1L, (N - E) % mmod);
        prln(nm % 2 == 1 ? mpow((int) (nm % mmod), N) : f(nm));
        close();
    }

    static int f(long n) {
        if (f.containsKey(n)) {
            return f.get(n);
        }
        f.put(n, madd(mmul(f(n / 2), f((n + 1) / 2)), mmul(g(n / 2), g((n + 1) / 2))));
        return f.get(n);
    }

    static int g(long n) {
        if (g.containsKey(n)) {
            return g.get(n);
        }
        g.put(n, madd(mmul(f(n / 2), g((n + 1) / 2)), mmul(g(n / 2), f((n + 1) / 2))));
        return g.get(n);
    }

    static int mmod = 998244353;

    static int madd(int a, int b) {
        return (a + b) % mmod;
    }

    static int madd(int... a) {
        int ans = a[0];
        for (int i = 1; i < a.length; ++i) {
            ans = madd(ans, a[i]);
        }
        return ans;
    }

    static int msub(int a, int b) {
        return (a - b + mmod) % mmod;
    }

    static int mmul(int a, int b) {
        return (int) ((long) a * b % mmod);
    }

    static int mmul(int... a) {
        int ans = a[0];
        for (int i = 1; i < a.length; ++i) {
            ans = mmul(ans, a[i]);
        }
        return ans;
    }

    static int minv(int x) {
        return mpow(x, mmod - 2);
    }

    static int mpow(int a, int b) {
        if (a == 0) {
            return 0;
        }
        int ans = 1;
        while (b > 0) {
            if ((b & 1) > 0) {
                ans = mmul(ans, a);
            }
            a = mmul(a, a);
            b >>= 1;
        }
        return ans;
    }

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // references
    // IBIG = 1e9 + 7
    // IMAX ~= 2e9
    // LMAX ~= 9e18

    // constants
    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;
    // math util
    static int minof(int a, int b, int c) {return min(a, min(b, c));}
    static int minof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); int min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static long minof(long a, long b, long c) {return min(a, min(b, c));}
    static long minof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); long min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static int maxof(int a, int b, int c) {return max(a, max(b, c));}
    static int maxof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); int max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static long maxof(long a, long b, long c) {return max(a, max(b, c));}
    static long maxof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); long max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static int powi(int a, int b) {if (a == 0) return 0; int ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static long powl(long a, int b) {if (a == 0) return 0; long ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static int fli(double d) {return (int) d;}
    static int cei(double d) {return (int) ceil(d);}
    static long fll(double d) {return (long) d;}
    static long cel(double d) {return (long) ceil(d);}
    static int gcf(int a, int b) {return b == 0 ? a : gcf(b, a % b);}
    static long gcf(long a, long b) {return b == 0 ? a : gcf(b, a % b);}
    static int lcm(int a, int b) {return a * b / gcf(a, b);}
    static long lcm(long a, long b) {return a * b / gcf(a, b);}
    static int randInt(int min, int max) {return __rand.nextInt(max - min + 1) + min;}
    static long mix(long x) {x += 0x9e3779b97f4a7c15L; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L; x = (x ^ (x >> 27)) * 0x94d049bb133111ebL; return x ^ (x >> 31);}
    // array util
    static void reverse(int[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {int swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(long[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {long swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(double[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {double swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(char[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {char swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void shuffle(int[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); int swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(long[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); long swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(double[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); double swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void rsort(int[] a) {shuffle(a); sort(a);}
    static void rsort(long[] a) {shuffle(a); sort(a);}
    static void rsort(double[] a) {shuffle(a); sort(a);}
    static int[] copy(int[] a) {int[] ans = new int[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static long[] copy(long[] a) {long[] ans = new long[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static double[] copy(double[] a) {double[] ans = new double[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static char[] copy(char[] a) {char[] ans = new char[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    // graph util
    static List<List<Integer>> g(int n) {List<List<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; ++i) g.add(new ArrayList<>()); return g;}
    static List<Set<Integer>> sg(int n) {List<Set<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; ++i) g.add(new HashSet<>()); return g;}
    static void c(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v); g.get(v).add(u);}
    static void cto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v);}
    static void dc(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v); g.get(v).remove(u);}
    static void dcto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v);}
    // input
    static void r() throws IOException {input = new StringTokenizer(rline());}
    static int ri() throws IOException {return Integer.parseInt(rline());}
    static long rl() throws IOException {return Long.parseLong(rline());}
    static double rd() throws IOException {return Double.parseDouble(rline());}
    static int[] ria(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni(); return a;}
    static int[] riam1(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni() - 1; return a;}
    static long[] rla(int n) throws IOException {long[] a = new long[n]; r(); for (int i = 0; i < n; ++i) a[i] = nl(); return a;}
    static double[] rda(int n) throws IOException {double[] a = new double[n]; r(); for (int i = 0; i < n; ++i) a[i] = nd(); return a;}
    static char[] rcha() throws IOException {return rline().toCharArray();}
    static String rline() throws IOException {return __in.readLine();}
    static String n() {return input.nextToken();}
    static int rni() throws IOException {r(); return ni();}
    static int ni() {return Integer.parseInt(n());}
    static long rnl() throws IOException {r(); return nl();}
    static long nl() {return Long.parseLong(n());}
    static double rnd() throws IOException {r(); return nd();}
    static double nd() {return Double.parseDouble(n());}
    static List<List<Integer>> rg(int n, int m) throws IOException {List<List<Integer>> g = g(n); for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1); return g;}
    static void rg(List<List<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1);}
    static List<List<Integer>> rdg(int n, int m) throws IOException {List<List<Integer>> g = g(n); for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1); return g;}
    static void rdg(List<List<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1);}
    static List<Set<Integer>> rsg(int n, int m) throws IOException {List<Set<Integer>> g = sg(n); for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1); return g;}
    static void rsg(List<Set<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1);}
    static List<Set<Integer>> rdsg(int n, int m) throws IOException {List<Set<Integer>> g = sg(n); for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1); return g;}
    static void rdsg(List<Set<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1);}
    // output
    static void pr(int i) {__out.print(i);}
    static void prln(int i) {__out.println(i);}
    static void pr(long l) {__out.print(l);}
    static void prln(long l) {__out.println(l);}
    static void pr(double d) {__out.print(d);}
    static void prln(double d) {__out.println(d);}
    static void pr(char c) {__out.print(c);}
    static void prln(char c) {__out.println(c);}
    static void pr(char[] s) {__out.print(new String(s));}
    static void prln(char[] s) {__out.println(new String(s));}
    static void pr(String s) {__out.print(s);}
    static void prln(String s) {__out.println(s);}
    static void pr(Object o) {__out.print(o);}
    static void prln(Object o) {__out.println(o);}
    static void prln() {__out.println();}
    static void pryes() {prln("yes");}
    static void pry() {prln("Yes");}
    static void prY() {prln("YES");}
    static void prno() {prln("no");}
    static void prn() {prln("No");}
    static void prN() {prln("NO");}
    static void pryesno(boolean b) {prln(b ? "yes" : "no");};
    static void pryn(boolean b) {prln(b ? "Yes" : "No");}
    static void prYN(boolean b) {prln(b ? "YES" : "NO");}
    static void prln(int... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(long... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(double... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static <T> void prln(Collection<T> c) {int n = c.size() - 1; Iterator<T> iter = c.iterator(); for (int i = 0; i < n; pr(iter.next()), pr(' '), ++i); if (n >= 0) prln(iter.next()); else prln();}
    static void h() {prln("hlfd"); flush();}
    static void flush() {__out.flush();}
    static void close() {__out.close();}}

import java.util.*;
import java.io.*;
import java.math.*;
public class Main{

	//static int p=1000000007;

	static int p =  998244353;

	static void err() {
		System.out.println(-1);
	}

	public static void main (String args[])throws IOException{
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);

		int t = 1;
		//t = sc.nextInt();

		while(t-->0) {

			int n=sc.nextInt(), m=sc.nextInt(), l=sc.nextInt(), r=sc.nextInt(), k=r-l, even=k/2+1, odd=(k+1)/2;

			if(n*m%2==1) {

				long ans=1;
				for(int i=0; i<n*m; i++) {
					ans*=(k+1);
					ans%=p;
				}
				out.print(ans);

			}else {

				long temp1=1, temp2=1;
				for(int i=0; i<n*m; i++) {
					temp1*=(odd+even);
					temp1%=p;
				}
				for(int i=0; i<n*m; i++) {
					temp2*=(odd-even);
					temp2%=p;
				}
				out.print(((temp1+temp2)%p)/2);
			}

		}
		out.flush();
	}

	public static String reverseString(String str){
	    StringBuilder sb=new StringBuilder(str);
	    sb.reverse();
	    return sb.toString();
	}

	static boolean isPalindrome(String str)
    {
        int i = 0, j = str.length() - 1;

        while (i < j) {

            if (str.charAt(i) != str.charAt(j))
                return false;

            i++;
            j--;
        }
        return true;
    }

	static void print(int[] arr) {
		for(int i=0; i<arr.length; i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}

	public static int abs(int x) {return ((x > 0) ? x : -x);}
	public static long abs(long x) {return ((x > 0) ? x : -x);}

	public static int max(int a, int b) {return Math.max(a, b);}
	public static long max(long a, long b) {return Math.max(a, b);}

	public static int min(int a, int b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a, b);}

	 static int gcd(int a, int b)
	    {
	        if (a == 0)
	            return b;
	        return gcd(b % a, a);
	    }

    static int modInverse(int a, int m)
    {
        int g = gcd(a, m);
        if (g != 1)
            return -1;
        else
        	return power(a, m - 2, m);

    }

    // To compute x^y under modulo m
    static int power(int x, int y, int m)
    {
        if (y == 0)
            return 1;

        int p = power(x, y / 2, m) % m;
        p = (p * p) % m;

        if (y % 2 == 0)
            return p;
        else
            return (x * p) % m;
    }

    static int[] primeGenerator(int num) {
    	int length=0, arr[]=new int[num], a=num, factor=1;
    	if(num%2==0) {
    		while(num%2==0) {
    			num/=2;
    			factor*=2;
    		}
    		arr[length++]=factor;
    	}
    	for(int i=3; i*i<=a; i++) {
    		factor=1;
    		if(num%i==0) {
        		while(num%i==0) {
        			num/=i;
        			factor*=i;
        		}
        		arr[length++]=factor;
    		}
    	}
    	if(num>1)
    		arr[length++]=num;
    	return Arrays.copyOfRange(arr, 0, length);
    }

    static boolean isPrime(int n)
    {
        // Corner cases
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        // This is checked so that we can skip
        // middle five numbers in below loop
        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}
}

class Pair{
	int x;
	int y;
	Pair(int a, int b){
		x=a;
		y=b;
	}

	void print() {
		System.out.println(this.x+" "+this.y);
	}
}

import java.util.*;
import java.io.*;
import java.math.*;
public class Main{

	//static int p=1000000007;

	static int p =  998244353;

	static void err() {
		System.out.println(-1);
	}

	public static void main (String args[])throws IOException{
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);

		int t = 1;
		//t = sc.nextInt();

		while(t-->0) {

			int n=sc.nextInt(), m=sc.nextInt(), l=sc.nextInt(), r=sc.nextInt(), k=r-l, even=k/2+1, odd=(k+1)/2;

			if(n*m%2==1) {

				int ans=1;
				for(int i=0; i<n*m; i++) {
					ans*=(k+1);
					ans%=p;
				}
				out.print(ans);

			}else {

				int temp1=1, temp2=1;
				for(int i=0; i<n*m; i++) {
					temp1*=(odd+even);
					temp1%=p;
				}
				for(int i=0; i<n*m; i++) {
					temp2*=(odd-even);
					temp2%=p;
				}
				out.print(((temp1+temp2)%p)/2);
			}

		}
		out.flush();
	}

	public static String reverseString(String str){
	    StringBuilder sb=new StringBuilder(str);
	    sb.reverse();
	    return sb.toString();
	}

	static boolean isPalindrome(String str)
    {
        int i = 0, j = str.length() - 1;

        while (i < j) {

            if (str.charAt(i) != str.charAt(j))
                return false;

            i++;
            j--;
        }
        return true;
    }

	static void print(int[] arr) {
		for(int i=0; i<arr.length; i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}

	public static int abs(int x) {return ((x > 0) ? x : -x);}
	public static long abs(long x) {return ((x > 0) ? x : -x);}

	public static int max(int a, int b) {return Math.max(a, b);}
	public static long max(long a, long b) {return Math.max(a, b);}

	public static int min(int a, int b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a, b);}

	 static int gcd(int a, int b)
	    {
	        if (a == 0)
	            return b;
	        return gcd(b % a, a);
	    }

    static int modInverse(int a, int m)
    {
        int g = gcd(a, m);
        if (g != 1)
            return -1;
        else
        	return power(a, m - 2, m);

    }

    // To compute x^y under modulo m
    static int power(int x, int y, int m)
    {
        if (y == 0)
            return 1;

        int p = power(x, y / 2, m) % m;
        p = (p * p) % m;

        if (y % 2 == 0)
            return p;
        else
            return (x * p) % m;
    }

    static int[] primeGenerator(int num) {
    	int length=0, arr[]=new int[num], a=num, factor=1;
    	if(num%2==0) {
    		while(num%2==0) {
    			num/=2;
    			factor*=2;
    		}
    		arr[length++]=factor;
    	}
    	for(int i=3; i*i<=a; i++) {
    		factor=1;
    		if(num%i==0) {
        		while(num%i==0) {
        			num/=i;
        			factor*=i;
        		}
        		arr[length++]=factor;
    		}
    	}
    	if(num>1)
    		arr[length++]=num;
    	return Arrays.copyOfRange(arr, 0, length);
    }

    static boolean isPrime(int n)
    {
        // Corner cases
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        // This is checked so that we can skip
        // middle five numbers in below loop
        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}
}

class Pair{
	int x;
	int y;
	Pair(int a, int b){
		x=a;
		y=b;
	}

	void print() {
		System.out.println(this.x+" "+this.y);
	}
}

import java.util.*;
import java.io.*;
import java.math.*;
public class Main{

	//static int p=1000000007;

	static long pr = 998244353;

	static BigInteger p =  new BigInteger(998244353+"");

	static void err() {
		System.out.println(-1);
	}

	public static void main (String args[])throws IOException{
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);

		int t = 1;
		//t = sc.nextInt();

		while(t-->0) {

			long n=sc.nextInt(), m=sc.nextInt(), l=sc.nextInt(), r=sc.nextInt(), k=r-l, even=k/2+1, odd=(k+1)/2;

			if((n*m)%2==1) {
				out.print(new BigInteger(k+1+"").modPow(new BigInteger(n*m+""), p));
			}else {

				BigInteger temp1 = new BigInteger(even+odd+"").modPow(new BigInteger(n*m+""), p);
				BigInteger temp2 = new BigInteger(even-odd+"").modPow(new BigInteger(n*m+""), p);

				out.println(((Long.parseLong(temp1.toString())+Long.parseLong(temp2.toString()))*(pr+1))%pr);
			}

		}
		out.flush();
	}

	public static String reverseString(String str){
	    StringBuilder sb=new StringBuilder(str);
	    sb.reverse();
	    return sb.toString();
	}

	static boolean isPalindrome(String str)
    {
        int i = 0, j = str.length() - 1;

        while (i < j) {

            if (str.charAt(i) != str.charAt(j))
                return false;

            i++;
            j--;
        }
        return true;
    }

	static void print(int[] arr) {
		for(int i=0; i<arr.length; i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}

	public static int abs(int x) {return ((x > 0) ? x : -x);}
	public static long abs(long x) {return ((x > 0) ? x : -x);}

	public static int max(int a, int b) {return Math.max(a, b);}
	public static long max(long a, long b) {return Math.max(a, b);}

	public static int min(int a, int b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a, b);}

	 static int gcd(int a, int b)
	    {
	        if (a == 0)
	            return b;
	        return gcd(b % a, a);
	    }

    static int modInverse(int a, int m)
    {
        int g = gcd(a, m);
        if (g != 1)
            return -1;
        else
        	return power(a, m - 2, m);

    }

    // To compute x^y under modulo m
    static int power(int x, int y, int m)
    {
        if (y == 0)
            return 1;

        int p = power(x, y / 2, m) % m;
        p = (p * p) % m;

        if (y % 2 == 0)
            return p;
        else
            return (x * p) % m;
    }

    static int[] primeGenerator(int num) {
    	int length=0, arr[]=new int[num], a=num, factor=1;
    	if(num%2==0) {
    		while(num%2==0) {
    			num/=2;
    			factor*=2;
    		}
    		arr[length++]=factor;
    	}
    	for(int i=3; i*i<=a; i++) {
    		factor=1;
    		if(num%i==0) {
        		while(num%i==0) {
        			num/=i;
        			factor*=i;
        		}
        		arr[length++]=factor;
    		}
    	}
    	if(num>1)
    		arr[length++]=num;
    	return Arrays.copyOfRange(arr, 0, length);
    }

    static boolean isPrime(int n)
    {
        // Corner cases
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        // This is checked so that we can skip
        // middle five numbers in below loop
        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}
}

class Pair{
	int x;
	int y;
	Pair(int a, int b){
		x=a;
		y=b;
	}

	void print() {
		System.out.println(this.x+" "+this.y);
	}
}

import java.util.Scanner;

public class E {
	static int MOD = 998244353;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int L = sc.nextInt();
		int R = sc.nextInt();
		int pow = R-L+1;
		if(n%2==0 || m%2==0) {
			int a = 0;
			int b =0;
			if(R%2==0 && L%2==0) {
				a = (L-R)/2+1;
				b = (L-R)/2;
			}
			else if(R%2==1 && L%2==1) {
				a = (R-L)/2;
				b = (R-L)/2+1;
			}
			else {
				a = (R-L+1)/2;
				b =(R-L+1)/2;
			}
			int fir = (a+b);
			int sec = a-b;
			long exp = (long) n*m;
			exp%=(MOD-1);
			long ans = exp(fir,(int) exp);
			ans+=exp(sec,(int) exp);
			ans%=MOD;
			long mult  = exp(2,MOD-2);
			ans*=mult;
			ans%=MOD;
			System.out.println(ans);
		}
		else {
			long exp = (long) n*m;
			exp%=(MOD-1);
			long ans = exp(pow,(int) exp);
			System.out.println(ans);
		}
	}
	static long exp(int base,int power) {
		if(base==0) return 0;
		if(power==0) return 1;
		if(power==1) return (base+MOD)%MOD;
		long ans = exp(base,power/2);
		ans = (ans*ans+MOD)%MOD;
		if(power%2==1) ans = (ans*base+MOD)%MOD;
		return (ans+MOD)%MOD;
	}
}

import java.util.Scanner;

public class E {
	static int MOD = 998244353;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int L = sc.nextInt();
		int R = sc.nextInt();
		int pow = R-L+1;
		if(n%2==0 || m%2==0) {
			int a = 0;
			int b =0;
			if(R%2==0 && L%2==0) {
				a = (R-L)/2+1;
				b = (R-L)/2;
			}
			else if(R%2==1 && L%2==1) {
				a = (R-L)/2;
				b = (R-L)/2+1;
			}
			else {
				a = (R-L+1)/2;
				b =(R-L+1)/2;
			}
			int fir = (a+b);
			int sec = a-b;
			long exp = (long) n*m;
			exp%=(MOD-1);
			long ans = exp(fir,(int) exp);
			ans+=exp(sec,(int) exp);
			ans%=MOD;
			long mult  = exp(2,MOD-2);
			ans*=mult;
			ans%=MOD;
			System.out.println(ans);
		}
		else {
			long exp = (long) n*m;
			exp%=(MOD-1);
			long ans = exp(pow,(int) exp);
			System.out.println(ans);
		}
	}
	static long exp(int base,int power) {
		if(base==0) return 0;
		if(power==0) return 1;
		if(power==1) return (base+MOD)%MOD;
		long ans = exp(base,power/2);
		ans = (ans*ans+MOD)%MOD;
		if(power%2==1) ans = (ans*base+MOD)%MOD;
		return (ans+MOD)%MOD;
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
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;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EHeightAllTheSame solver = new EHeightAllTheSame();
        solver.solve(1, in, out);
        out.close();
    }

    static class EHeightAllTheSame {
        final static long mod = 998244353;

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int m = in.scanInt();
            int l = in.scanInt();
            int r = in.scanInt();

            long total = CodeX.power(r - l + 1, n * m, mod);
            if ((n * m) % 2 == 1) {
                out.println(total);
            } else {

                long range = r - l + 1;

                if (range % 2 == 0) {
                    out.println((total * CodeX.modinv(2, mod)) % mod);
                } else {
                    out.println(((total + 1) * CodeX.modinv(2, mod)) % mod);
                }

            }

        /*
            0 1

               2*2*2*2

               00--> 00  1
               01--> 01  0
               02--> 00  1
               10--> 10  0
               11--> 11  1
               12--> 10  0
               20--> 00  1
               21--> 01  0
               22--> 00  1
         */
        /*
           - -
         */

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }

    static class CodeX {
        public static long power(long x, long y, long p) {
            long res = 1;
            x = x % p;
            while (y > 0) {

                if ((y & 1) != 0)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }

        public static long modinv(long k, long mod) {
            return power(k, mod - 2, mod);
        }

    }
}

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

public class E630 {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        long n = sc.nextLong(); long m = sc.nextLong(); long l = sc.nextLong(); long r = sc.nextLong();
        long need = (n * m) % 2;
        long a = r - l + 1;
        if (a % 2 == 0) {
            long ret = pow(a, n * m);
            ret = (ret * inv(2)) % mod;
            out.println(ret);
        } else {
            if (need == 0) {
                long ret = (pow(a, n * m) + 1) % mod;
                ret = (ret * inv(2)) % mod;
                out.println(ret);
            } else {
                long ret = (pow(a, n * m) - 1) % mod;
                ret = (ret * inv(2)) % mod;
                out.println(ret);
            }
        }
        out.close();
    }

    static long[] fac;
    static long mod = 998244353;

    static void initFac(long n) {
        fac[0] = 1;
        for (int i = 1; i <= n; i++) {
            fac[i] = (fac[i - 1]  * i) % mod;
        }
    }

    static long nck(int n, int k) {
        if (n < k)
            return 0;
        long den = inv((int) (fac[k] * fac[n - k] % mod));
        return fac[n] * den % mod;
    }

    static long pow(long b, long e) {
        long ans = 1;
        while (e > 0) {
            if (e % 2 == 1)
                ans = ans * b % mod;
            e >>= 1;
            b = b * b % mod;
        }
        return ans;
    }

    static long inv(long x) {
        return pow(x, mod - 2);
    }

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

}

import java.util.Scanner;
import java.math.BigInteger;
import java.util.Vector;

public class Main {
	public static void main(String[] args) {
		BigInteger MOD = BigInteger.valueOf(998244353);

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long L = sc.nextLong();
		long R = sc.nextLong();

		long k = R - L + 1;

		if (n * m % 2 == 1) {
			BigInteger base = BigInteger.valueOf(n * m);
			BigInteger exp = BigInteger.valueOf(k);
			System.out.println(base.modPow(exp, MOD));
		} else {
			long e, o;
			BigInteger E, O, exp;
			e = k / 2;
			if ((k % 2 == 1) && (R % 2 == 0)) {
				e++;
			}
			o = k - e;
			E = BigInteger.valueOf(e);
			O = BigInteger.valueOf(o);
			exp = BigInteger.valueOf(n * m);
			BigInteger a = E.add(O).modPow(exp, MOD);
			BigInteger b = E.subtract(O).modPow(exp, MOD);
			System.out.println(a.add(b).divide(BigInteger.valueOf(2)).mod(MOD));

		}

	}
}

import java.util.Scanner;
import java.math.BigInteger;
import java.util.Vector;

public class Main {
	public static void main(String[] args) {
		BigInteger MOD = BigInteger.valueOf(998244353);

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long L = sc.nextLong();
		long R = sc.nextLong();

		long k = R - L + 1;

		if (n * m % 2 == 1) {
			BigInteger exp = BigInteger.valueOf(n * m);
			BigInteger base = BigInteger.valueOf(k);
			System.out.println(base.modPow(exp, MOD));
		} else {
			long e, o;
			BigInteger E, O, exp;
			e = k / 2;
			if ((k % 2 == 1) && (R % 2 == 0)) {
				e++;
			}
			o = k - e;
			E = BigInteger.valueOf(e);
			O = BigInteger.valueOf(o);
			exp = BigInteger.valueOf(n * m);
			BigInteger a = E.add(O).modPow(exp, MOD);
			BigInteger b = E.subtract(O).modPow(exp, MOD);
			System.out.println(a.add(b).divide(BigInteger.valueOf(2)).mod(MOD));

		}

	}
}

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

public class E {

    public static void main(String args[]) throws IOException {
        FastScanner in = new FastScanner(System.in);
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        int t = 1;
        while (t-- > 0) {
            solve(in, out);
        }
        out.flush();
    }

    public static void solve(FastScanner in, BufferedWriter out) throws IOException {
        int n = in.nextInt();
        int m = in.nextInt();
        int L = in.nextInt();
        int R = in.nextInt();
        int k = R - L + 1;
        long ans = 1;
        long mod = 998244353;
        if ((n * m) % 2 != 0) {
            for (int i = 0; i < n * m; i++) ans = (ans * k) % mod;
        } else {
            int E = (k + 1) / 2;
            int O = (k) / 2;
            for (int i = 0; i < n * m; i++) {
                ans = (ans * (E + O)) % mod;
            }
            ans = ans + (E - O);
            ans = (ans * (mod + 1) / 2) % mod;
            ans %= mod;
        }
        out.write(ans + "\n");
    }

    private static class FastScanner {
        private BufferedReader reader;

        private StringTokenizer tokenizer;

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }

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

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

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

public class E {

    public static void main(String args[]) throws IOException {
        FastScanner in = new FastScanner(System.in);
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        int t = 1;
        while (t-- > 0) {
            solve(in, out);
        }
        out.flush();
    }

    public static void solve(FastScanner in, BufferedWriter out) throws IOException {
        int n = in.nextInt();
        int m = in.nextInt();
        int L = in.nextInt();
        int R = in.nextInt();
        int k = R - L + 1;
        long ans = 1;
        long mod = 998244353;
        if ((n * m) % 2 != 0) {
            for (int i = 0; i < n * m; i++) ans = (ans * k) % mod;
        } else {
            int E = (k + 1) / 2;
            int O = (k) / 2;
            long ans2 = 1;
            for (int i = 0; i < n * m; i++) {
                ans = (ans * (E + O)) % mod;
                ans2 = (ans2 * (E - O)) % mod;
            }
            ans = ans + ans2;
            ans /= 2;
            ans %= mod;
        }
        out.write(ans + "\n");
    }

    private static class FastScanner {
        private BufferedReader reader;

        private StringTokenizer tokenizer;

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }

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

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

import java.util.*;

public class HeightOfAllSame {
    static int modulo = 998244353;

    static long pwmd(long a, long n) {
        if (n == 0) {
            return 1;
        }
        long pt = pwmd(a, n / 2);
        pt *= pt;
        pt %= modulo;
        if (n % 2 != 0) {
            pt *= a;
            pt %= modulo;
        }
        return pt;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int r = sc.nextInt();

        long t = (long) r - l + 1;
        long e = r / 2 + (l - 1) / 2;
        long o = t - e;

        long x = (long) n * m;

        if (x % 2 != 0) {
            System.out.println(pwmd(t, x));
        } else {
            long l1 = pwmd(e + o, x);
            long l2 = pwmd(o - e, x);
            long ans = pwmd(t, x) - (l1 - l2) / 2;

            System.out.println(ans % modulo);
        }

    }
}

import java.util.*;

public class HeightOfAllSame {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int r = sc.nextInt();

        long t = (long) r - l + 1;
        long e = r / 2 + (l - 1) / 2;
        long o = t - e;

        long x = (long) n * m;

        int modulo = 998244353;
        long l1 = (long) Math.pow(e + o, x);
        long l2 = (long) Math.pow(o - e, x);
        long ans = (long) Math.pow(t, x) - (l1 - l2) / 2;

        System.out.println(ans % modulo);
    }
}

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

public class CF1332E extends PrintWriter {
	CF1332E() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1332E o = new CF1332E(); o.main(); o.flush();
	}

	static final int MD = 998244353;
	long power(int a, int k) {
		if (k == 0)
			return 1;
		long p = power(a, k / 2);
		p = p * p % MD;
		if (k % 2 == 1)
			p = p * a % MD;
		return p;
	}
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int r = sc.nextInt();
		if (l == r) {
			println(1);
			return;
		}
		long ans = power((r - l + 1) % MD, (int) ((long) n * m % (MD - 1)));
		if (n % 2 == 0 || m % 2 == 0) {
			int inv2 = (MD + 1) / 2;
			ans = ans * inv2 % MD;
		}
		println(ans);
	}
}

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

public class CF1332E extends PrintWriter {
	CF1332E() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1332E o = new CF1332E(); o.main(); o.flush();
	}

	static final int MD = 998244353;
	long power(int a, int k) {
		if (k == 0)
			return 1;
		long p = power(a, k / 2);
		p = p * p % MD;
		if (k % 2 == 1)
			p = p * a % MD;
		return p;
	}
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int r = sc.nextInt();
		if (l == r) {
			println(1);
			return;
		}
		long k = r - l + 1;
		long c = (long) n * m;
		if (n % 2 == 0 || m % 2 == 0) {
			long a = k / 2, b = k - a;
			a = (long) a * a;
			b = (long) b * b;
			k = a + b;
			c /= 2;
		}
		long ans = power((int) (k % MD), (int) (c % (MD - 1)));
		println(ans);
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            EHeightAllTheSame solver = new EHeightAllTheSame();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class EHeightAllTheSame {
        Modular mod = new Modular(998244353);
        Debug debug = new Debug(true);

        public int odd(int n) {
            return (n + 1) / 2;
        }

        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            int m = in.readInt();
            int l = in.readInt();
            int r = in.readInt();
            int odd = odd(r) - odd(l - 1);
            int even = (r - l + 1) - odd;
            debug.debug("odd", odd);
            debug.debug("even", even);
            ModMatrix matrix = new ModMatrix(2, 2);
            matrix.set(0, 0, even);
            matrix.set(0, 1, odd);
            matrix.set(1, 0, odd);
            matrix.set(1, 1, even);
            matrix = ModMatrix.pow(matrix, (long) n * m, mod);
            ModMatrix vector = new ModMatrix(2, 1);
            vector.set(0, 0, 1);

            ModMatrix ans = ModMatrix.mul(matrix, vector, mod);
            out.println(ans.get(0, 0));
        }

    }

    static class Debug {
        private boolean offline;
        private PrintStream out = System.err;

        public Debug(boolean enable) {
            offline = enable && System.getSecurityManager() == null;
        }

        public Debug debug(String name, int x) {
            if (offline) {
                debug(name, "" + x);
            }
            return this;
        }

        public Debug debug(String name, String x) {
            if (offline) {
                out.printf("%s=%s", name, x);
                out.println();
            }
            return this;
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 20];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

    }

    static class Modular {
        int m;

        public int getMod() {
            return m;
        }

        public Modular(int m) {
            this.m = m;
        }

        public Modular(long m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public Modular(double m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public int valueOf(int x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return x;
        }

        public int valueOf(long x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return (int) x;
        }

        public int mul(int x, int y) {
            return valueOf((long) x * y);
        }

        public int plus(int x, int y) {
            return valueOf(x + y);
        }

        public String toString() {
            return "mod " + m;
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }

    static class ModMatrix {
        int[][] mat;
        int n;
        int m;

        public ModMatrix(ModMatrix model) {
            n = model.n;
            m = model.m;
            mat = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    mat[i][j] = model.mat[i][j];
                }
            }
        }

        public ModMatrix(int n, int m) {
            this.n = n;
            this.m = m;
            mat = new int[n][m];
        }

        public ModMatrix(int[][] mat) {
            if (mat.length == 0 || mat[0].length == 0) {
                throw new IllegalArgumentException();
            }
            this.n = mat.length;
            this.m = mat[0].length;
            this.mat = mat;
        }

        public void fill(int v) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    mat[i][j] = v;
                }
            }
        }

        public void asStandard(Modular mod) {
            fill(0);
            if (mod.getMod() == 1) {
                return;
            }
            for (int i = 0; i < n && i < m; i++) {
                mat[i][i] = 1;
            }
        }

        public void set(int i, int j, int val) {
            mat[i][j] = val;
        }

        public int get(int i, int j) {
            return mat[i][j];
        }

        public static ModMatrix mul(ModMatrix a, ModMatrix b, Modular modular) {
            ModMatrix c = new ModMatrix(a.n, b.m);
            for (int i = 0; i < c.n; i++) {
                for (int j = 0; j < c.m; j++) {
                    for (int k = 0; k < a.m; k++) {
                        c.mat[i][j] = modular.plus(c.mat[i][j], modular.mul(a.mat[i][k], b.mat[k][j]));
                    }
                }
            }
            return c;
        }

        public static ModMatrix pow(ModMatrix x, long n, Modular modular) {
            if (n == 0) {
                ModMatrix r = new ModMatrix(x.n, x.m);
                r.asStandard(modular);
                return r;
            }
            ModMatrix r = pow(x, n >> 1, modular);
            r = ModMatrix.mul(r, r, modular);
            if (n % 2 == 1) {
                r = ModMatrix.mul(r, x, modular);
            }
            return r;
        }

        public String toString() {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    builder.append(mat[i][j]).append(' ');
                }
                builder.append('\n');
            }
            return builder.toString();
        }

    }
}

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

public class heightsame
{
	static long N, M, L, R;
	static BigInteger mod = BigInteger.valueOf(998244353);
	public static void main(String[] args) throws IOException
	{
		Scanner s = new Scanner(System.in);
		N = s.nextLong();
		M = s.nextLong();
		L = s.nextLong();
		R = s.nextLong();
		BigInteger diff = BigInteger.valueOf(R-L+1);
		BigInteger prod = BigInteger.valueOf(N*M);
		BigInteger ans = diff.modPow(prod, mod.multiply(BigInteger.valueOf(2)));
		if (prod.mod(BigInteger.valueOf(2)).equals(BigInteger.ZERO))
		{
			ans = ans.divide((ans.add(BigInteger.ONE)).divide(BigInteger.valueOf(2)));
		}
		System.out.println(ans.mod(mod));
		s.close();
	}
}

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

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);

 		long n =fr.nextLong() ,m =fr.nextLong() ,l =fr.nextLong() ,r =fr.nextLong() ;	n *= m ;
 		if ((n&1l)==0l)	--n ;	r -= l ;	++r ;
		op.println(pow(r,n,998244353l)) ;	op.flush();	op.close();
	}
	static long pow (long b , long e , long md) {
		if (e==0l)	return 1l;
		if (e==1l)	return b;
		long dm =pow(b,e/2l,md) ;	dm *= dm ;	dm %= md ;
		if ((e&1l)==1l)	{	dm *= b ;	dm %= md ;	}
		return dm ;
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

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

			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

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

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

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

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);

 		long n =fr.nextLong() ,m =fr.nextLong() ,l =fr.nextLong() ,r =fr.nextLong() ,md =998244353l ;
 		n *= m ;	if ((n&1l)==0l)	--n ;	r =(r-l+md)%md ;	r =(r+1l)%md ;
		op.println(pow(r,n,md)) ;	op.flush();	op.close();
	}
	static long pow (long b , long e , long md) {
		if (e==0l)	return 1l;
		if (e==1l)	return b;
		long dm =pow(b,e/2l,md) ;	dm *= dm ;	dm %= md ;
		if ((e&1l)==1l)	{	dm *= b ;	dm %= md ;	}
		return dm ;
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

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

			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

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

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

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

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);

 		long n =fr.nextLong() ,m =fr.nextLong() ,l =fr.nextLong() ,r =fr.nextLong() ,md =998244353l ;
 		n *= m ;	if ((n&1l)==0l)	--n ;
 		r %= md ;	l %= md ;	r =(r-l+md)%md ;	r =(r+1l)%md ;
		op.println(pow(r,n,md)) ;	op.flush();	op.close();
	}
	static long pow (long b , long e , long md) {
		if (e==0l)	return 1l;
		if (e==1l)	return b;
		long dm =pow(b,e/2l,md) ;	dm *= dm ;	dm %= md ;
		if ((e&1l)==1l)	{	dm *= b ;	dm %= md ;	}
		return dm ;
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

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

			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

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

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

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

public class E1332 {

	static int mod = 998244353;

	static long[][] matMul(long[][] A, long[][] B, int p, int q, int r) // C(p x r) = A(p x q) x (q x r) -- O(p x q x r)
	{
		long[][] C = new long[p][r];
		for (int i = 0; i < p; ++i)
			for (int j = 0; j < r; ++j)
				for (int k = 0; k < q; ++k) {
					C[i][j] += (A[i][k] * B[k][j]) % mod;
					C[i][j] %= mod;
				}
		return C;
	}

	/*
	 * 4. Square Matrix Exponentiation
	 */
	static long[][] matPow(long[][] base, long p) {
		int n = base.length;
		long[][] ans = new long[n][n];
		for (int i = 0; i < n; i++)
			ans[i][i] = 1;
		while (p != 0) {
			if ((p & 1) == 1)
				ans = matMul(ans, base, n, n, n);
			base = matMul(base, base, n, n, n);
			p >>= 1;
		}

		return ans;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long n = sc.nextInt();
		long m = sc.nextInt();
		int l = sc.nextInt();
		int r = sc.nextInt();
		int e = r / 2 - l / 2;
		int o = (r - l + 1) - e;
		long[][] mat = { { e, o }, { o, e } };
		long[][] ans = matPow(mat, n * m);
		ans = matMul(new long[][] { { 1l, 0l } }, ans, 1, 2, 2);
		pw.println(ans[0][0]);
		pw.close();

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextInt();
			return arr;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}

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

public class E1332 {

	static int mod = 998244353;

	static long[][] matMul(long[][] A, long[][] B, int p, int q, int r) // C(p x r) = A(p x q) x (q x r) -- O(p x q x r)
	{
		long[][] C = new long[p][r];
		for (int i = 0; i < p; ++i)
			for (int j = 0; j < r; ++j)
				for (int k = 0; k < q; ++k) {
					C[i][j] += (A[i][k] * B[k][j]) % mod;
					C[i][j] %= mod;
				}
		return C;
	}

	/*
	 * 4. Square Matrix Exponentiation
	 */
	static long[][] matPow(long[][] base, long p) {
		int n = base.length;
		long[][] ans = new long[n][n];
		for (int i = 0; i < n; i++)
			ans[i][i] = 1;
		while (p != 0) {
			if ((p & 1) == 1)
				ans = matMul(ans, base, n, n, n);
			base = matMul(base, base, n, n, n);
			p >>= 1;
		}

		return ans;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long n = sc.nextInt();
		long m = sc.nextInt();
		int l = sc.nextInt();
		int r = sc.nextInt();
		int e = (r) / 2 - (l-1) / 2;
		int o = (r - l + 1) - e;
		long[][] mat = { { e, o }, { o, e } };
		long[][] ans = matPow(mat, n * m);
		ans = matMul(new long[][] { { 1l, 0l } }, ans, 1, 2, 2);
		pw.println(ans[0][0]);
		pw.close();

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextInt();
			return arr;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}

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

public class E1332 {

	static int mod = 998244353;

	static long[][] matMul(long[][] A, long[][] B, int p, int q, int r) // C(p x r) = A(p x q) x (q x r) -- O(p x q x r)
	{
		long[][] C = new long[p][r];
		for (int i = 0; i < p; ++i)
			for (int j = 0; j < r; ++j)
				for (int k = 0; k < q; ++k) {
					C[i][j] += (A[i][k] * B[k][j]) % mod;
					C[i][j] %= mod;
				}
		return C;
	}

	/*
	 * 4. Square Matrix Exponentiation
	 */
	static long[][] matPow(long[][] base, long p) {
		int n = base.length;
		long[][] ans = new long[n][n];
		for (int i = 0; i < n; i++)
			ans[i][i] = 1;
		while (p != 0) {
			if ((p & 1) == 1)
				ans = matMul(ans, base, n, n, n);
			base = matMul(base, base, n, n, n);
			p >>= 1;
		}

		return ans;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long n = sc.nextInt();
		long m = sc.nextInt();
		int l = sc.nextInt();
		int r = sc.nextInt();
		int e = (r) / 2 - (l-1) / 2;
		int o = (r - l + 1) - e;
		long[][] mat = { { e, o }, { o, e } };
		long[][] ans = matPow(mat, n * m);
		ans = matMul(new long[][] { { 1l, 0l } }, ans, 1, 2, 2);
		pw.println(ans[0][1]);
		pw.close();

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextInt();
			return arr;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}

/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class HeightAllTheSame {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        long N = sc.nextLong();
        long M = sc.nextLong();
        long L = sc.nextLong();
        long R = sc.nextLong();

        long E = (R - L + 1) / 2 + (R % 2 == 0 && L % 2 == 0 ? 1 : 0);
        long O = (R - L + 1) - E;
        // Key thing to observe: if we have any valid starting position
        // with an EVEN number of ODD-heighted blocks, then it'll be possible.
        // Basically, we notice that we can flip any pair of OE blocks, and
        // then in this way we can move any odd blocks together, then flip those
        // OO into an EE pair. So, the starting position just needs an even number
        // of odd blocks for this invariant of the same parity of number of ODD
        // blocks to be satisfied

        // This can be visualized as the generating function (E+O)^(NM)
        // since this illustrates the distribution of ways to make each of the NM cells
        // However, we only want the O^(2k) terms for all k. So, we use
        // the trick of adding it to (E-O)^(NM), since all odd terms will cancel
        // Then, we divide by 2, and we have the total answer!
        long ans = (fastExpo(E + O, N * M) + fastExpo(E - O, N * M)) % mod;
        ans = (ans * modInv(2)) % mod; // divide by 2 now
        out.println(ans);
        out.close();
    }

    static long mod = 998244353;

    static long modInv(long x) {
        return fastExpo(x, mod - 2);
    }

    static long fastExpo(long x, long k) {
        if (k == 0) {
            return 1;
        }
        else if (k == 1) {
            return x;
        }
        else {
            long root = fastExpo(x, k / 2);
            long ans = (root * root) % mod;
            if (k % 2 == 1) {
                ans = (ans * x) % mod;
            }
            return ans;
        }
    }

    static class FastScanner {
        public int BS = 1<<16;
        public char NC = (char)0;
        byte[] buf = new byte[BS];
        int bId = 0, size = 0;
        char c = NC;
        double cnt = 1;
        BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            }
            catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar(){
            while(bId==size) {
                try {
                    size = in.read(buf);
                }catch(Exception e) {
                    return NC;
                }
                if(size==-1)return NC;
                bId=0;
            }
            return (char)buf[bId++];
        }

        public int nextInt() {
            return (int)nextLong();
        }

        public int[] nextInts(int N, int dx) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong() + dx;
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt=1;
            boolean neg = false;
            if(c==NC)c=getChar();
            for(;(c<'0' || c>'9'); c = getChar()) {
                if(c=='-')neg=true;
            }
            long res = 0;
            for(; c>='0' && c <='9'; c=getChar()) {
                res = (res<<3)+(res<<1)+c-'0';
                cnt*=10;
            }
            return neg?-res:res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c!='.' ? cur:cur+nextLong()/cnt;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c>32) {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c!='\n') {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if(c>32)return true;
            while(true) {
                c=getChar();
                if(c==NC)return false;
                else if(c>32)return true;
            }
        }
    }
}

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import java.util.*;

public class template {

	InputStream is;
	PrintWriter out;
	String INPUT = "";
	int mod = 998244353;

	void solve() {
		int n = ni();
		int m = ni();
		int l = ni();
		int r = ni();
		int t = r-l+1;
		int e = r/2-(l-1)/2;
		int o = t-e;

		if((n*1l*m) % 2 == 0) {
			long total = power(r-l+1l,n*1l*m,mod*1l);
			long t1 = power(e+o,n*m,mod) - power(e-o , n*m,mod)+mod;
			t1 = t1%mod;
			t1 = t1*modInverse(2, mod);
			t1 = t1%mod;
			total -= t1;
			total += mod;
			total = total%mod;
			out.println(total);
		}
		else {
			out.println(power(r-l+1l,n*1l*m,mod*1l));
		}

	}
	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
		//tr(System.currentTimeMillis()-s+"ms");
	}

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

	private void sort(int[] arr, int start, int end){
        if(start >= end) return;
        int mid = start + (end - start) / 2;
        sort(arr, start, mid);
        sort(arr, mid +1, end);
        merge(arr, start, mid, end);
    }
	private void merge(int[] arr, int start, int mid, int end){
        int i = start, j = mid + 1;
        int[] help = new int[end - start + 1];
        int c = 0;
        while(i <= mid && j <= end){
            help[c++] = arr[j] < arr[i] ? arr[j++] : arr[i++];
        }
        while(i <= mid){
            help[c++] = arr[i++];
        }
        while(j <= end){
            help[c++] = arr[j++];
        }
        for(int k = 0; k < help.length; k++){
            arr[start + k] = help[k];
        }
    }
	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 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 char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

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

	private int[][] na(int n , int m)
	{
		int[][] a = new int[n][m];
		for(int i = 0;i < n;i++)
			for(int j = 0 ; j<m ; j++) a[i][j] = ni();
		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 * 10 + (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 display2D(int a[][]) {
		for(int i[] : a) {
			for(int j : i) {
				out.print(j+" ");
			}
			out.println();
		}
	}

	int[][] creategraph(int n , int m) {
		int g[][] = new int[n+1][];

		int from[] = new int[m];
		int to[] = new int[m];
		int ct[] = new int[n+1];

		for(int i = 0 ; i<m; i++) {
			from[i] = ni();
			to[i] = ni();
			ct[from[i]]++;
			ct[to[i]]++;
		}

		int parent[] = new int[n+1];

		for(int i = 0 ; i<n+1 ; i++) g[i] = new int[ct[i]];

		for(int i = 0 ; i<m ; i++) {
			g[from[i]][--ct[from[i]]] = to[i];
			g[to[i]][--ct[to[i]]] = from[i];
		}

		return g;
	}

	static long __gcd(long a, long b)
	{

		if(b == 0)
		{
			return a;
		}
		else
		{
			return __gcd(b, a % b);
		}
	}

	// To compute x^y under modulo m
	static long power(long x, long y, long p)
	{

		// Initialize result
		long res = 1;

		// Update x if it is more than or
		// equal to p
		x = x % p;

		while (y > 0)
		{

			// If y is odd, multiply x
			// with result
			if (y % 2 == 1)
				res = (res * x) % p;

			// y must be even now
			y = y >> 1; // y = y/2
		x = (x * x) % p;
		}

		return res;
	}

	// Function to find modular
	// inverse of a under modulo m
	// Assumption: m is prime
	static long modInverse(long a, int m)
	{
		if (__gcd(a, m) != 1) {
			//System.out.print("Inverse doesn't exist");
			return -1;
		}

		else {

			// If a and m are relatively prime, then
			// modulo inverse is a^(m-2) mode m
			//			System.out.println("Modular multiplicative inverse is "
			//											+power(a, m - 2, m));
			return power(a, m - 2, m);
		}
	}

	static long nCrModPFermat(int n, int r,
			int p , long fac[])
	{

		// Base case
		if (r == 0)
			return 1;

		// Fill factorial array so that we
		// can find all factorial of r, n
		// and n-r
		long t = (fac[n]* modInverse(fac[r], p))%p;

		return ( (t* modInverse(fac[n-r], p))% p);
	}

	private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}

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

public class E implements Runnable {
	boolean judge = false;
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		long n = scn.nextLong(), m = scn.nextLong();
		long l = scn.nextLong(), r = scn.nextLong(), mod = 998244353;

		if((n * m) % 2 == 1) {
			out.println(pow(r - l + 1, n * m, mod));
			return;
		}

		if((r - l + 1) % 2 == 1) {
			long x = (r - l + 1) / 2, y = r - l + 1 - x;
			long k = n * m;

			long xk = pow(x, k + 1, mod);
			long yk = pow(y, k + 1, mod);

			long a = (xk + yk) * pow(x + y, mod - 2, mod) % mod;
			long b = 0;
			if(y > x) {
				b = (yk - xk) * pow(y - x, mod - 2, mod) % mod;
			} else {
				b = (xk - yk) * pow(y - x, mod - 2, mod) % mod;
			}

			long z = (a + b + mod) % mod;
			z = z * pow(2, mod - 2, mod) % mod;
			out.println(z);
			return;
		}

		long x = (r - l + 1) / 2;
		long k = n * m;
		long two = pow(2, k - 1, mod);

		long ans = (pow(x, k, mod) * two) % mod;
		out.println(ans);
	}

	long func(long k, long z, long mod) {
		if(z == 0) {
			return 0;
		}
		long x = z / 2, y = z - x;
		if(x == 0 || y == 0) {
			return 1;
		}

		long ans = 0;
		for(long a = 0; a <= k; a += 2) {
			long b = k - a;

			long rv = pow(x, a, mod) * pow(y, b, mod) % mod;
			ans = (ans + rv) % mod;
		}

		return ans;
	}

	long pow(long a, long x, long m) {
		long rv = 1;
		while (x != 0) {
			if ((x & 1) == 1) {
				rv = (rv * a) % m;
			}
			a = (a * a) % m;
			x = x >> 1;
		}
		return rv;
	}

	public void run() {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null || judge;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) {
		new Thread(null, new E(), "Main", 1 << 28).start();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

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

		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++];
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

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

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

		char[] next(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);
		}

		int nextInt() {
			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 * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			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();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

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

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		int[][] next2DInt(int n, int m) {
			int[][] arr = new int[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextIntArray(m);
			}
			return arr;
		}

		long[][] next2DLong(int n, int m) {
			long[][] arr = new long[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLongArray(m);
			}
			return arr;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				int c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		long[] shuffle(long[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				long c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		int[] uniq(int[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			int[] rv = new int[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		long[] uniq(long[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			long[] rv = new long[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		int[] reverse(int[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		long[] reverse(long[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		int[] compress(int[] arr) {
			int n = arr.length;
			int[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}

		long[] compress(long[] arr) {
			int n = arr.length;
			long[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}
	}
}

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

public class E implements Runnable {
	boolean judge = false;
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		long n = scn.nextLong(), m = scn.nextLong();
		long l = scn.nextLong(), r = scn.nextLong(), mod = 998244353;

		if((n * m) % 2 == 1) {
			out.println(pow(r - l + 1, n * m, mod));
			return;
		}

		if((r - l + 1) % 2 == 1) {
			long x = (r - l + 1) / 2, y = r - l + 1 - x;
			long k = n * m;

			long xk = pow(x, k + 1, mod);
			long yk = pow(y, k + 1, mod);

			long a = (xk + yk) * pow(x + y, mod - 2, mod) % mod;
			long b = 0;
			if(y > x) {
				b = (yk - xk) * pow(y - x, mod - 2, mod) % mod;
			} else {
				b = (xk - yk) * pow(x - y, mod - 2, mod) % mod;
			}

			long z = (a + b + mod) % mod;
			z = z * pow(2, mod - 2, mod) % mod;
			out.println(z);
			return;
		}

		long x = (r - l + 1) / 2;
		long k = n * m;
		long two = pow(2, k - 1, mod);

		long ans = (pow(x, k, mod) * two) % mod;
		out.println(ans);
	}

	long func(long k, long z, long mod) {
		if(z == 0) {
			return 0;
		}
		long x = z / 2, y = z - x;
		if(x == 0 || y == 0) {
			return 1;
		}

		long ans = 0;
		for(long a = 0; a <= k; a += 2) {
			long b = k - a;

			long rv = pow(x, a, mod) * pow(y, b, mod) % mod;
			ans = (ans + rv) % mod;
		}

		return ans;
	}

	long pow(long a, long x, long m) {
		long rv = 1;
		while (x != 0) {
			if ((x & 1) == 1) {
				rv = (rv * a) % m;
			}
			a = (a * a) % m;
			x = x >> 1;
		}
		return rv;
	}

	public void run() {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null || judge;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) {
		new Thread(null, new E(), "Main", 1 << 28).start();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

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

		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++];
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

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

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

		char[] next(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);
		}

		int nextInt() {
			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 * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			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();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

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

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		int[][] next2DInt(int n, int m) {
			int[][] arr = new int[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextIntArray(m);
			}
			return arr;
		}

		long[][] next2DLong(int n, int m) {
			long[][] arr = new long[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLongArray(m);
			}
			return arr;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				int c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		long[] shuffle(long[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				long c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		int[] uniq(int[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			int[] rv = new int[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		long[] uniq(long[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			long[] rv = new long[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		int[] reverse(int[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		long[] reverse(long[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		int[] compress(int[] arr) {
			int n = arr.length;
			int[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}

		long[] compress(long[] arr) {
			int n = arr.length;
			long[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}
	}
}

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

/**
 * Created with: IntelliJ IDEA
 * Function:
 * User: zhangzhe041@ke.com
 * Date: 2020-04-06 10:08:07
 */
public class HeightAllTheSame {

    int n,m,l,r;

    int mod = 998_244_353;

    public static void main(String[] args) throws IOException {
        new HeightAllTheSame();

    }

    HeightAllTheSame() throws IOException {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n = in.nextInt();
        m = in.nextInt();
        l = in.nextInt();
        r  =in.nextInt();

        long tmp = n * m;
        int x = (r - l + 1) / 2;
        int y = (r - l +1) - x;
        if((tmp & 1) == 1){
            out.print(pow2(r - l + 1, tmp));
        }else{
            out.print((pow2(x + y, tmp) + pow2(x - y, tmp)) * pow2(2, mod - 2) % mod);
        }
        out.close();
    }

    long pow2(int a, long b){
        long base = a;
        long ans = 1;
        while(b > 0){

            if((b & 1) == 1){
                ans = ans * base % mod;
            }
            b = b >> 1;
            base = base * base % mod;
        }
        return ans;
    }

    class Scanner{
        BufferedReader br;
        StringTokenizer st;

        Scanner(InputStream inputStream){br = new BufferedReader(new InputStreamReader(inputStream));}

        String next() throws IOException {
            if(st == null || !st.hasMoreTokens()){
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

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

        Long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}

import java.util.*;
import java.io.*;
public class e {
	static final long mod = 998_244_353;

	static long num, L, R;
	static long numEven, numOdd;
	static long[][] mat;
	public static void main(String[] args) {
		FS sc = new FS();
		num = sc.nextLong() * sc.nextLong();
		L = sc.nextLong();
		R = sc.nextLong();

		numEven = numOdd = (R - L + 1) / 2;
		if(L % 2 == R % 2) {
			if(L % 2 == 0) ++numEven;
			else ++numOdd;
		}

		mat = new long[2][2];
		mat[0][0] = mat[1][1] = numEven % mod;
		mat[0][1] = mat[1][0] = numOdd % mod;

		// do the thing
		long[][] out = pow(mat, num);

		System.out.println(out[0][0]);
	}
	static long[][] pow(long[][] a, long pow){
		long[][] out = new long[2][2];
		if(pow == 0) {
			out[0][0] = out[1][1] = 1;
			return out;
		}

		out = pow(a, pow / 2);
		out = mult(out, out);
		if(pow % 2 == 1) out = mult(out, a);
		return out;
	}
	static long[][] mult(long[][] a, long[][] b){
		long[][] out = new long[2][2];
		for(int i = 0; i < 2; ++i) {
			for(int j = 0; j < 2; ++j) {
				// dot product of row i of a and col j of b
				long curr = 0;
				for(int k = 0; k < 2; ++k) curr = (curr + a[i][k] * b[k][j]) % mod;
				out[i][j] = curr;
			}
		}
		return out;
	}
	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}
/*
2 2 1 4

*/

import java.util.*;
import java.io.*;
public class e {
	static final long mod = 998_244_353;

	static long num, L, R;
	static long numEven, numOdd;
	static long[][] mat;
	public static void main(String[] args) {
		FS sc = new FS();
		num = sc.nextLong() * sc.nextLong();
		L = sc.nextLong();
		R = sc.nextLong();

		numEven = numOdd = (R - L + 1) / 2;
		if(L == R) {
			if(L % 2 == 0) ++numEven;
			else ++numOdd;
		}

		mat = new long[2][2];
		mat[0][0] = mat[1][1] = numEven;
		mat[0][1] = mat[1][0] = numOdd;

		// do the thing
		long[][] out = pow(mat, num);

		System.out.println(out[0][0]);
	}
	static long[][] pow(long[][] a, long pow){
		long[][] out = new long[2][2];
		if(pow == 0) {
			out[0][0] = out[1][1] = 1;
			return out;
		}

		out = pow(a, pow / 2);
		out = mult(out, out);
		if(pow % 2 == 1) out = mult(out, a);
		return out;
	}
	static long[][] mult(long[][] a, long[][] b){
		long[][] out = new long[2][2];
		for(int i = 0; i < 2; ++i) {
			for(int j = 0; j < 2; ++j) {
				// dot product of row i of a and col j of b
				long curr = 0;
				for(int k = 0; k < 2; ++k) curr += (a[i][k] * b[k][j]) % mod;
				out[i][j] = curr;
			}
		}
		return out;
	}
	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

import java.util.*;
import java.io.*;
public class e {
	static final long mod = 998_244_353;

	static long num, L, R;
	static long numEven, numOdd;
	static long[][] mat;
	public static void main(String[] args) {
		FS sc = new FS();
		num = sc.nextLong() * sc.nextLong();
		L = sc.nextLong();
		R = sc.nextLong();

		numEven = numOdd = (R - L + 1) / 2;
		if(L == R) {
			if(L % 2 == 0) ++numEven;
			else ++numOdd;
		}

		mat = new long[2][2];
		mat[0][0] = mat[1][1] = numEven % mod;
		mat[0][1] = mat[1][0] = numOdd % mod;

		// do the thing
		long[][] out = pow(mat, num);

		System.out.println(out[0][0]);
	}
	static long[][] pow(long[][] a, long pow){
		long[][] out = new long[2][2];
		if(pow == 0) {
			out[0][0] = out[1][1] = 1;
			return out;
		}

		out = pow(a, pow / 2);
		out = mult(out, out);
		if(pow % 2 == 1) out = mult(out, a);
		return out;
	}
	static long[][] mult(long[][] a, long[][] b){
		long[][] out = new long[2][2];
		for(int i = 0; i < 2; ++i) {
			for(int j = 0; j < 2; ++j) {
				// dot product of row i of a and col j of b
				long curr = 0;
				for(int k = 0; k < 2; ++k) curr = (curr + a[i][k] * b[k][j]) % mod;
				out[i][j] = curr;
			}
		}
		return out;
	}
	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

import java.util.*;
import java.io.*;
public class EdD {
	static long[] mods = {1000000007, 998244353, 1000000009};
	static long mod = mods[1];
	public static MyScanner sc;
    public static PrintWriter out;
	public static void main(String[] omkar) throws Exception{
		// TODO Auto-generated method stub
 		sc = new MyScanner();
 		PrintWriter out = new PrintWriter(System.out);
 		long n = sc.nextLong();
 		long m = sc.nextLong();
 		long l = sc.nextLong();
 		long r = sc.nextLong();
 		long ans = power(r-l+1, (n*m)%mod);
 		if ((n*m)%2 == 0){
 			ans = ans*power(2, mod-2);
 			ans%=mod;
 		}
 		if (l == r)
 			ans = 1;
 		out.println(ans);

 		out.close();
 	}
	public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<Integer>();
		for (int i : array)
			copy.add(i);
		Collections.sort(copy);
		for(int i = 0;i<array.length;i++)
			array[i] = copy.get(i);
	}
	static String[] readArrayString(int n){
		String[] array = new String[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.next();
		return array;
	}
	static int[] readArrayInt(int n){
    	int[] array = new int[n];
    	for(int j = 0;j<n;j++)
    		array[j] = sc.nextInt();
    	return array;
    }
	static int[] readArrayInt1(int n){
		int[] array = new int[n+1];
		for(int j = 1;j<=n;j++){
			array[j] = sc.nextInt();
		}
		return array;
	}
	static long[] readArrayLong(int n){
		long[] array = new long[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextLong();
		return array;
	}
	static double[] readArrayDouble(int n){
		double[] array = new double[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextDouble();
		return array;
	}
	static int minIndex(int[] array){
		int minValue = Integer.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(long[] array){
		long minValue = Long.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(double[] array){
		double minValue = Double.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static long power(long x, long y){
		if (y == 0)
			return 1;
		if (y%2 == 1)
			return (x*power(x, y-1))%mod;
		return power((x*x)%mod, y/2)%mod;
	}
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

import java.util.*;
import java.io.*;
public class EdD {
	static long[] mods = {1000000007, 998244353, 1000000009};
	static long mod = mods[1];
	public static MyScanner sc;
    public static PrintWriter out;
	public static void main(String[] omkar) throws Exception{
		// TODO Auto-generated method stub
 		sc = new MyScanner();
 		PrintWriter out = new PrintWriter(System.out);
 		long n = sc.nextLong();
 		long m = sc.nextLong();
 		long l = sc.nextLong();
 		long r = sc.nextLong();
 		long ans = power((r-l+1)%mod, (n*m)%mod);
		if ((r-l+1)%2 == 0){
			ans = ans*power(2, mod-2);
			ans%=mod;
		}
		else{
			ans+=1;
			ans%=mod;
			ans = ans*power(2, mod-2);
			ans%=mod;

		}
 		out.println(ans);

 		out.close();
 	}
	public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<Integer>();
		for (int i : array)
			copy.add(i);
		Collections.sort(copy);
		for(int i = 0;i<array.length;i++)
			array[i] = copy.get(i);
	}
	static String[] readArrayString(int n){
		String[] array = new String[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.next();
		return array;
	}
	static int[] readArrayInt(int n){
    	int[] array = new int[n];
    	for(int j = 0;j<n;j++)
    		array[j] = sc.nextInt();
    	return array;
    }
	static int[] readArrayInt1(int n){
		int[] array = new int[n+1];
		for(int j = 1;j<=n;j++){
			array[j] = sc.nextInt();
		}
		return array;
	}
	static long[] readArrayLong(int n){
		long[] array = new long[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextLong();
		return array;
	}
	static double[] readArrayDouble(int n){
		double[] array = new double[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextDouble();
		return array;
	}
	static int minIndex(int[] array){
		int minValue = Integer.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(long[] array){
		long minValue = Long.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(double[] array){
		double minValue = Double.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static long power(long x, long y){
		if (y == 0)
			return 1;
		if (y%2 == 1)
			return (x*power(x, y-1))%mod;
		return power((x*x)%mod, y/2)%mod;
	}
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

import java.util.*;
import java.io.*;
public class EdD {
	static long[] mods = {1000000007, 998244353, 1000000009};
	static long mod = mods[1];
	public static MyScanner sc;
    public static PrintWriter out;
	public static void main(String[] omkar) throws Exception{
		// TODO Auto-generated method stub
 		sc = new MyScanner();
 		PrintWriter out = new PrintWriter(System.out);
 		long n = sc.nextLong();
 		long m = sc.nextLong();
 		long l = sc.nextLong();
 		long r = sc.nextLong();
 		long ans = power((r-l+1)%mod, (n*m)%mod);
		if ((n*m)%2 == 0){
			ans = ans*power(r-l+1, mod-2);
			ans%=mod;
			if (l%2 == r%2){
				ans = ans*((r-l+2)/2);
				ans%=mod;
			}
			else{
				ans = ans*((r-l+1)/2);
				ans%=mod;
			}
		}
 		out.println(ans);

 		out.close();
 	}
	public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<Integer>();
		for (int i : array)
			copy.add(i);
		Collections.sort(copy);
		for(int i = 0;i<array.length;i++)
			array[i] = copy.get(i);
	}
	static String[] readArrayString(int n){
		String[] array = new String[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.next();
		return array;
	}
	static int[] readArrayInt(int n){
    	int[] array = new int[n];
    	for(int j = 0;j<n;j++)
    		array[j] = sc.nextInt();
    	return array;
    }
	static int[] readArrayInt1(int n){
		int[] array = new int[n+1];
		for(int j = 1;j<=n;j++){
			array[j] = sc.nextInt();
		}
		return array;
	}
	static long[] readArrayLong(int n){
		long[] array = new long[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextLong();
		return array;
	}
	static double[] readArrayDouble(int n){
		double[] array = new double[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextDouble();
		return array;
	}
	static int minIndex(int[] array){
		int minValue = Integer.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(long[] array){
		long minValue = Long.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(double[] array){
		double minValue = Double.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static long power(long x, long y){
		if (y == 0)
			return 1;
		if (y%2 == 1)
			return (x*power(x, y-1))%mod;
		return power((x*x)%mod, y/2)%mod;
	}
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

import java.util.*;
import java.io.*;
public class EdD {
	static long[] mods = {1000000007, 998244353, 1000000009};
	static long mod = mods[1];
	public static MyScanner sc;
    public static PrintWriter out;
	public static void main(String[] omkar) throws Exception{
		// TODO Auto-generated method stub
 		sc = new MyScanner();
 		PrintWriter out = new PrintWriter(System.out);
 		long n = sc.nextLong();
 		long m = sc.nextLong();
 		long l = sc.nextLong();
 		long r = sc.nextLong();
 		long ans = power((r-l+1)%mod, (n*m)%mod);
 			ans = ans*power(2, mod-2);
 			ans%=mod;
 		if (l == r)
 			ans = 1;
 		out.println(ans);

 		out.close();
 	}
	public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<Integer>();
		for (int i : array)
			copy.add(i);
		Collections.sort(copy);
		for(int i = 0;i<array.length;i++)
			array[i] = copy.get(i);
	}
	static String[] readArrayString(int n){
		String[] array = new String[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.next();
		return array;
	}
	static int[] readArrayInt(int n){
    	int[] array = new int[n];
    	for(int j = 0;j<n;j++)
    		array[j] = sc.nextInt();
    	return array;
    }
	static int[] readArrayInt1(int n){
		int[] array = new int[n+1];
		for(int j = 1;j<=n;j++){
			array[j] = sc.nextInt();
		}
		return array;
	}
	static long[] readArrayLong(int n){
		long[] array = new long[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextLong();
		return array;
	}
	static double[] readArrayDouble(int n){
		double[] array = new double[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextDouble();
		return array;
	}
	static int minIndex(int[] array){
		int minValue = Integer.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(long[] array){
		long minValue = Long.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(double[] array){
		double minValue = Double.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static long power(long x, long y){
		if (y == 0)
			return 1;
		if (y%2 == 1)
			return (x*power(x, y-1))%mod;
		return power((x*x)%mod, y/2)%mod;
	}
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

import java.util.*;
import java.io.*;
public class EdD {
	static long[] mods = {1000000007, 998244353, 1000000009};
	static long mod = mods[1];
	public static MyScanner sc;
    public static PrintWriter out;
	public static void main(String[] omkar) throws Exception{
		// TODO Auto-generated method stub
 		sc = new MyScanner();
 		PrintWriter out = new PrintWriter(System.out);
 		long n = sc.nextLong();
 		long m = sc.nextLong();
 		long l = sc.nextLong();
 		long r = sc.nextLong();
 		long ans = power((r-l+1)%mod, (n*m)%mod);
 		if ((n*m)%2 == 0){
 			ans = ans*power(2, mod-2);
 			ans%=mod;
 		}
 		if (l == r)
 			ans = 1;
 		out.println(ans);

 		out.close();
 	}
	public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<Integer>();
		for (int i : array)
			copy.add(i);
		Collections.sort(copy);
		for(int i = 0;i<array.length;i++)
			array[i] = copy.get(i);
	}
	static String[] readArrayString(int n){
		String[] array = new String[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.next();
		return array;
	}
	static int[] readArrayInt(int n){
    	int[] array = new int[n];
    	for(int j = 0;j<n;j++)
    		array[j] = sc.nextInt();
    	return array;
    }
	static int[] readArrayInt1(int n){
		int[] array = new int[n+1];
		for(int j = 1;j<=n;j++){
			array[j] = sc.nextInt();
		}
		return array;
	}
	static long[] readArrayLong(int n){
		long[] array = new long[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextLong();
		return array;
	}
	static double[] readArrayDouble(int n){
		double[] array = new double[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextDouble();
		return array;
	}
	static int minIndex(int[] array){
		int minValue = Integer.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(long[] array){
		long minValue = Long.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(double[] array){
		double minValue = Double.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static long power(long x, long y){
		if (y == 0)
			return 1;
		if (y%2 == 1)
			return (x*power(x, y-1))%mod;
		return power((x*x)%mod, y/2)%mod;
	}
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

import java.util.*;
import java.io.*;
public class EdD {
	static long[] mods = {1000000007, 998244353, 1000000009};
	static long mod = mods[1];
	public static MyScanner sc;
    public static PrintWriter out;
	public static void main(String[] omkar) throws Exception{
		// TODO Auto-generated method stub
 		sc = new MyScanner();
 		PrintWriter out = new PrintWriter(System.out);
 		long n = sc.nextLong();
 		long m = sc.nextLong();
 		long l = sc.nextLong();
 		long r = sc.nextLong();
 		long ans = power((r-l+1)%mod, (n*m)%mod);
 		if ((n*m)%2 == 0){
 			if (r%2 == l%2)
 				ans+=1;
			ans *=power(2, mod-2);
			ans%=mod;
 		}
 		out.println(ans);

 		out.close();
 	}
	public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<Integer>();
		for (int i : array)
			copy.add(i);
		Collections.sort(copy);
		for(int i = 0;i<array.length;i++)
			array[i] = copy.get(i);
	}
	static String[] readArrayString(int n){
		String[] array = new String[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.next();
		return array;
	}
	static int[] readArrayInt(int n){
    	int[] array = new int[n];
    	for(int j = 0;j<n;j++)
    		array[j] = sc.nextInt();
    	return array;
    }
	static int[] readArrayInt1(int n){
		int[] array = new int[n+1];
		for(int j = 1;j<=n;j++){
			array[j] = sc.nextInt();
		}
		return array;
	}
	static long[] readArrayLong(int n){
		long[] array = new long[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextLong();
		return array;
	}
	static double[] readArrayDouble(int n){
		double[] array = new double[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextDouble();
		return array;
	}
	static int minIndex(int[] array){
		int minValue = Integer.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(long[] array){
		long minValue = Long.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(double[] array){
		double minValue = Double.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static long power(long x, long y){
		if (y == 0)
			return 1;
		if (y%2 == 1)
			return (x*power(x, y-1))%mod;
		return power((x*x)%mod, y/2)%mod;
	}
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

import java.util.*;
import java.io.*;
import java.security.acl.Owner;

public class codeforces {

	public static void main(String[] args) throws Exception {
		long n=sc.nextLong();
		long m=sc.nextLong();
		long l=sc.nextLong();
		long r=sc.nextLong();
		long k=1l*r-l+1;
		long num=1l*n*m;
		long even=k/2;
		long odd=k/2;
//		fac=new long[(int) k];
//		fac[0]=1;
//		fac[1]=1;
//		for(int i=2;i<k;i++) {
//			fac[i]=(fac[i-1]*i)%mod;
//		}
		if(k%2==1) {
		if(l%2==1) {
			odd++;
		}else {
			even++;
		}

		}

		long ans=0;
		if(num%2==1) {
			ans=Pow(k, num, mod);
			pw.println(ans);
		}
		else {
			if(odd>even) {
			ans=(((Pow(odd+even, num, mod)-Pow(odd-even, num, mod))%mod)*Pow(2, mod - 2, mod)+1)%mod;
			}else{

				ans=(((Pow(odd+even, num, mod)-Pow(even-odd, num, mod))%mod)*Pow(2, mod - 2, mod))%mod;
			}
			pw.println(ans);

		}
		pw.close();
	}
    static class Scanner {

        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int curbuf;
        private int lenbuf;

        public Scanner(InputStream in) {
            this.in = in;
            this.curbuf = this.lenbuf = 0;
        }

        public boolean hasNextByte() {
            if (curbuf >= lenbuf) {
                curbuf = 0;
                try {
                    lenbuf = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0)
                    return false;
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[curbuf++];
            else
                return -1;
        }

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

        private void skip() {
            while (hasNextByte() && isSpaceChar(buffer[curbuf]))
                curbuf++;
        }

        public boolean hasNext() {
            skip();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (!isSpaceChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

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

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

    }

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	public static long GCD(long a, long b) {
		if (b == 0)
			return a;
		if (a == 0)
			return b;
		return (a > b) ? GCD(a % b, b) : GCD(a, b % a);
	}

	public static long LCM(long a, long b) {
		return a * b / GCD(a, b);
	}

	static long Pow(long a, long e, int mod) // O(log e)
	{
		a %= mod;
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static long nc(int n, int r) {
		if (n < r)
			return 0;
		long v = fac[n];
		v *= Pow(fac[r], mod - 2, mod);
		v %= mod;
		v *= Pow(fac[n - r], mod - 2, mod);
		v %= mod;
		return v;
	}

	public static boolean isprime(long a) {
		if (a == 0 || a == 1) {
			return false;
		}
		if (a == 2) {
			return true;
		}
		for (int i = 2; i < Math.sqrt(a) + 1; i++) {
			if (a % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static boolean isPal(String s) {
		boolean t = true;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				t = false;
				break;
			}
		}
		return t;
	}

	public static long RandomPick(long[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static int RandomPick(int[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static void PH(String s, boolean reverse) {
		prelen = s.length();
		HashsArray[HashsArrayInd] = new int[prelen + 1];
		prepow = new int[prelen];
		if (HashsArrayInd == 0) {
			int[] mods = { 1173017693, 1173038827, 1173069731, 1173086977, 1173089783, 1173092147, 1173107093,
					1173114391, 1173132347, 1173144367, 1173150103, 1173152611, 1173163993, 1173174127, 1173204679,
					1173237343, 1173252107, 1173253331, 1173255653, 1173260183, 1173262943, 1173265439, 1173279091,
					1173285331, 1173286771, 1173288593, 1173298123, 1173302129, 1173308827, 1173310451, 1173312383,
					1173313571, 1173324371, 1173361529, 1173385729, 1173387217, 1173387361, 1173420799, 1173421499,
					1173423077, 1173428083, 1173442159, 1173445549, 1173451681, 1173453299, 1173454729, 1173458401,
					1173459491, 1173464177, 1173468943, 1173470041, 1173477947, 1173500677, 1173507869, 1173522919,
					1173537359, 1173605003, 1173610253, 1173632671, 1173653623, 1173665447, 1173675577, 1173675787,
					1173684683, 1173691109, 1173696907, 1173705257, 1173705523, 1173725389, 1173727601, 1173741953,
					1173747577, 1173751499, 1173759449, 1173760943, 1173761429, 1173762509, 1173769939, 1173771233,
					1173778937, 1173784637, 1173793289, 1173799607, 1173802823, 1173808003, 1173810919, 1173818311,
					1173819293, 1173828167, 1173846677, 1173848941, 1173853249, 1173858341, 1173891613, 1173894053,
					1173908039, 1173909203, 1173961541, 1173968989, 1173999193 };
			mod = RandomPick(mods);
			int[] primes = { 59, 61, 67, 71, 73, 79, 83, 89, 97, 101 };
			prime = RandomPick(primes);
		}
		prepow[0] = 1;
		if (!reverse) {

			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
			}

		} else {
			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[prelen - 1 - i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);

			}

		}

		HashsArrayInd++;

	}

	public static int PHV(int l, int r, int n, boolean reverse) {
		if (l > r) {
			return 0;
		}
		int val = (int) ((1l * HashsArray[n - 1][r] + mod - HashsArray[n - 1][l - 1]) % mod);
		if (!reverse) {

			val = (int) ((1l * val * prepow[prelen - l]) % mod);
		} else {
			val = (int) ((1l * val * prepow[r - 1]) % mod);
		}
		return val;
	}
	 static int modInverse(long a, int m)
	    {
	        a = a % m;
	        for (int x = 1; x < m; x++)
	           if ((a * x) % m == 1)
	              return x;
	        return 1;
	    }
	static int[][] HashsArray;
	static int HashsArrayInd = 0;
	static int[] prepow;
	static int prelen = 0;
	static int prime = 31;
	static long fac[];
	static int mod = 998244353;
	static Random rn = new Random();
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);
}

import java.util.*;
import java.io.*;
import java.security.acl.Owner;

public class codeforces {

	public static void main(String[] args) throws Exception {
		long n=sc.nextLong();
		long m=sc.nextLong();
		long l=sc.nextLong();
		long r=sc.nextLong();
		long k=1l*r-l+1;
		long num=1l*n*m;
		long even=k/2;
		long odd=k/2;
//		fac=new long[(int) k];
//		fac[0]=1;
//		fac[1]=1;
//		for(int i=2;i<k;i++) {
//			fac[i]=(fac[i-1]*i)%mod;
//		}
		if(k%2==1) {
		if(l%2==1) {
			odd++;
		}else {
			even++;
		}

		}

		long ans=0;
		if(num%2==1) {
			ans=Pow(k, num, mod);
			pw.println(ans);
		}
		else {
			if(odd>even) {
			ans=(((Pow(odd+even, num, mod)-Pow(odd-even, num, mod))%mod)*Pow(2, mod - 2, mod)+1)%mod;
			}else if(even>odd){

				ans=(((Pow(odd+even, num, mod)-Pow(even-odd, num, mod))%mod)*Pow(2, mod - 2, mod)+1)%mod;
			}else {
				ans=(((Pow(odd+even, num, mod)-Pow(even-odd, num, mod))%mod)*Pow(2, mod - 2, mod))%mod;
			}
			pw.println(ans);

		}
		pw.close();
	}
    static class Scanner {

        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int curbuf;
        private int lenbuf;

        public Scanner(InputStream in) {
            this.in = in;
            this.curbuf = this.lenbuf = 0;
        }

        public boolean hasNextByte() {
            if (curbuf >= lenbuf) {
                curbuf = 0;
                try {
                    lenbuf = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0)
                    return false;
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[curbuf++];
            else
                return -1;
        }

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

        private void skip() {
            while (hasNextByte() && isSpaceChar(buffer[curbuf]))
                curbuf++;
        }

        public boolean hasNext() {
            skip();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (!isSpaceChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

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

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

    }

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	public static long GCD(long a, long b) {
		if (b == 0)
			return a;
		if (a == 0)
			return b;
		return (a > b) ? GCD(a % b, b) : GCD(a, b % a);
	}

	public static long LCM(long a, long b) {
		return a * b / GCD(a, b);
	}

	static long Pow(long a, long e, int mod) // O(log e)
	{
		a %= mod;
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static long nc(int n, int r) {
		if (n < r)
			return 0;
		long v = fac[n];
		v *= Pow(fac[r], mod - 2, mod);
		v %= mod;
		v *= Pow(fac[n - r], mod - 2, mod);
		v %= mod;
		return v;
	}

	public static boolean isprime(long a) {
		if (a == 0 || a == 1) {
			return false;
		}
		if (a == 2) {
			return true;
		}
		for (int i = 2; i < Math.sqrt(a) + 1; i++) {
			if (a % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static boolean isPal(String s) {
		boolean t = true;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				t = false;
				break;
			}
		}
		return t;
	}

	public static long RandomPick(long[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static int RandomPick(int[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static void PH(String s, boolean reverse) {
		prelen = s.length();
		HashsArray[HashsArrayInd] = new int[prelen + 1];
		prepow = new int[prelen];
		if (HashsArrayInd == 0) {
			int[] mods = { 1173017693, 1173038827, 1173069731, 1173086977, 1173089783, 1173092147, 1173107093,
					1173114391, 1173132347, 1173144367, 1173150103, 1173152611, 1173163993, 1173174127, 1173204679,
					1173237343, 1173252107, 1173253331, 1173255653, 1173260183, 1173262943, 1173265439, 1173279091,
					1173285331, 1173286771, 1173288593, 1173298123, 1173302129, 1173308827, 1173310451, 1173312383,
					1173313571, 1173324371, 1173361529, 1173385729, 1173387217, 1173387361, 1173420799, 1173421499,
					1173423077, 1173428083, 1173442159, 1173445549, 1173451681, 1173453299, 1173454729, 1173458401,
					1173459491, 1173464177, 1173468943, 1173470041, 1173477947, 1173500677, 1173507869, 1173522919,
					1173537359, 1173605003, 1173610253, 1173632671, 1173653623, 1173665447, 1173675577, 1173675787,
					1173684683, 1173691109, 1173696907, 1173705257, 1173705523, 1173725389, 1173727601, 1173741953,
					1173747577, 1173751499, 1173759449, 1173760943, 1173761429, 1173762509, 1173769939, 1173771233,
					1173778937, 1173784637, 1173793289, 1173799607, 1173802823, 1173808003, 1173810919, 1173818311,
					1173819293, 1173828167, 1173846677, 1173848941, 1173853249, 1173858341, 1173891613, 1173894053,
					1173908039, 1173909203, 1173961541, 1173968989, 1173999193 };
			mod = RandomPick(mods);
			int[] primes = { 59, 61, 67, 71, 73, 79, 83, 89, 97, 101 };
			prime = RandomPick(primes);
		}
		prepow[0] = 1;
		if (!reverse) {

			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
			}

		} else {
			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[prelen - 1 - i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);

			}

		}

		HashsArrayInd++;

	}

	public static int PHV(int l, int r, int n, boolean reverse) {
		if (l > r) {
			return 0;
		}
		int val = (int) ((1l * HashsArray[n - 1][r] + mod - HashsArray[n - 1][l - 1]) % mod);
		if (!reverse) {

			val = (int) ((1l * val * prepow[prelen - l]) % mod);
		} else {
			val = (int) ((1l * val * prepow[r - 1]) % mod);
		}
		return val;
	}
	 static int modInverse(long a, int m)
	    {
	        a = a % m;
	        for (int x = 1; x < m; x++)
	           if ((a * x) % m == 1)
	              return x;
	        return 1;
	    }
	static int[][] HashsArray;
	static int HashsArrayInd = 0;
	static int[] prepow;
	static int prelen = 0;
	static int prime = 31;
	static long fac[];
	static int mod = 998244353;
	static Random rn = new Random();
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);
}

import java.util.*;
import java.io.*;
import java.security.acl.Owner;

public class codeforces {

	public static void main(String[] args) throws Exception {
		long n=sc.nextLong();
		long m=sc.nextLong();
		long l=sc.nextLong();
		long r=sc.nextLong();
		long k=1l*r-l+1;
		long num=1l*n*m;
		long even=k/2;
		long odd=k/2;
//		fac=new long[(int) k];
//		fac[0]=1;
//		fac[1]=1;
//		for(int i=2;i<k;i++) {
//			fac[i]=(fac[i-1]*i)%mod;
//		}
		if(k%2==1) {
		if(l%2==1) {
			odd++;
		}else {
			even++;
		}

		}

		long ans=0;
		if(num%2==1) {
			ans=Pow(k, num, mod);
			pw.println(ans);
		}
		else {
			if(odd>even) {
			ans=(((Pow(odd+even, num, mod)-Pow(odd-even, num, mod))%mod)*Pow(2, mod - 2, mod))%mod;
			}else{

				ans=(((Pow(odd+even, num, mod)-Pow(even-odd, num, mod))%mod)*Pow(2, mod - 2, mod))%mod;
			}
			pw.println(ans);

		}
		pw.close();
	}
    static class Scanner {

        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int curbuf;
        private int lenbuf;

        public Scanner(InputStream in) {
            this.in = in;
            this.curbuf = this.lenbuf = 0;
        }

        public boolean hasNextByte() {
            if (curbuf >= lenbuf) {
                curbuf = 0;
                try {
                    lenbuf = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0)
                    return false;
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[curbuf++];
            else
                return -1;
        }

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

        private void skip() {
            while (hasNextByte() && isSpaceChar(buffer[curbuf]))
                curbuf++;
        }

        public boolean hasNext() {
            skip();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (!isSpaceChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

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

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

    }

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	public static long GCD(long a, long b) {
		if (b == 0)
			return a;
		if (a == 0)
			return b;
		return (a > b) ? GCD(a % b, b) : GCD(a, b % a);
	}

	public static long LCM(long a, long b) {
		return a * b / GCD(a, b);
	}

	static long Pow(long a, long e, int mod) // O(log e)
	{
		a %= mod;
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static long nc(int n, int r) {
		if (n < r)
			return 0;
		long v = fac[n];
		v *= Pow(fac[r], mod - 2, mod);
		v %= mod;
		v *= Pow(fac[n - r], mod - 2, mod);
		v %= mod;
		return v;
	}

	public static boolean isprime(long a) {
		if (a == 0 || a == 1) {
			return false;
		}
		if (a == 2) {
			return true;
		}
		for (int i = 2; i < Math.sqrt(a) + 1; i++) {
			if (a % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static boolean isPal(String s) {
		boolean t = true;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				t = false;
				break;
			}
		}
		return t;
	}

	public static long RandomPick(long[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static int RandomPick(int[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static void PH(String s, boolean reverse) {
		prelen = s.length();
		HashsArray[HashsArrayInd] = new int[prelen + 1];
		prepow = new int[prelen];
		if (HashsArrayInd == 0) {
			int[] mods = { 1173017693, 1173038827, 1173069731, 1173086977, 1173089783, 1173092147, 1173107093,
					1173114391, 1173132347, 1173144367, 1173150103, 1173152611, 1173163993, 1173174127, 1173204679,
					1173237343, 1173252107, 1173253331, 1173255653, 1173260183, 1173262943, 1173265439, 1173279091,
					1173285331, 1173286771, 1173288593, 1173298123, 1173302129, 1173308827, 1173310451, 1173312383,
					1173313571, 1173324371, 1173361529, 1173385729, 1173387217, 1173387361, 1173420799, 1173421499,
					1173423077, 1173428083, 1173442159, 1173445549, 1173451681, 1173453299, 1173454729, 1173458401,
					1173459491, 1173464177, 1173468943, 1173470041, 1173477947, 1173500677, 1173507869, 1173522919,
					1173537359, 1173605003, 1173610253, 1173632671, 1173653623, 1173665447, 1173675577, 1173675787,
					1173684683, 1173691109, 1173696907, 1173705257, 1173705523, 1173725389, 1173727601, 1173741953,
					1173747577, 1173751499, 1173759449, 1173760943, 1173761429, 1173762509, 1173769939, 1173771233,
					1173778937, 1173784637, 1173793289, 1173799607, 1173802823, 1173808003, 1173810919, 1173818311,
					1173819293, 1173828167, 1173846677, 1173848941, 1173853249, 1173858341, 1173891613, 1173894053,
					1173908039, 1173909203, 1173961541, 1173968989, 1173999193 };
			mod = RandomPick(mods);
			int[] primes = { 59, 61, 67, 71, 73, 79, 83, 89, 97, 101 };
			prime = RandomPick(primes);
		}
		prepow[0] = 1;
		if (!reverse) {

			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
			}

		} else {
			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[prelen - 1 - i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);

			}

		}

		HashsArrayInd++;

	}

	public static int PHV(int l, int r, int n, boolean reverse) {
		if (l > r) {
			return 0;
		}
		int val = (int) ((1l * HashsArray[n - 1][r] + mod - HashsArray[n - 1][l - 1]) % mod);
		if (!reverse) {

			val = (int) ((1l * val * prepow[prelen - l]) % mod);
		} else {
			val = (int) ((1l * val * prepow[r - 1]) % mod);
		}
		return val;
	}
	 static int modInverse(long a, int m)
	    {
	        a = a % m;
	        for (int x = 1; x < m; x++)
	           if ((a * x) % m == 1)
	              return x;
	        return 1;
	    }
	static int[][] HashsArray;
	static int HashsArrayInd = 0;
	static int[] prepow;
	static int prelen = 0;
	static int prime = 31;
	static long fac[];
	static int mod = 998244353;
	static Random rn = new Random();
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);
}

import java.util.*;
import java.io.*;
import java.security.acl.Owner;

public class codeforces {

	public static void main(String[] args) throws Exception {
		long n=sc.nextLong();
		long m=sc.nextLong();
		long l=sc.nextLong();
		long r=sc.nextLong();
		long k=1l*r-l+1;
		long num=1l*n*m;
		long even=k/2;
		long odd=k/2;
//		fac=new long[(int) k];
//		fac[0]=1;
//		fac[1]=1;
//		for(int i=2;i<k;i++) {
//			fac[i]=(fac[i-1]*i)%mod;
//		}
		if(k%2==1) {
		if(l%2==1) {
			odd++;
		}else {
			even++;
		}

		}

		long ans=0;
		if(num%2==1) {
			ans=Pow(k, num, mod);
			pw.println(ans);
		}
		else {
			if(odd>even) {
			ans=(((Pow(odd+even, num, mod)-Pow(odd-even, num, mod))%mod)*Pow(2, mod - 2, mod)+1)%mod;
			}else if(even>odd){

				ans=(((Pow(odd+even, num, mod)-Pow(even-odd, num, mod))%mod)*Pow(2, mod - 2, mod)-1)%mod;
			}else {
				ans=(((Pow(odd+even, num, mod)-Pow(even-odd, num, mod))%mod)*Pow(2, mod - 2, mod))%mod;
			}
			pw.println(ans);

		}
		pw.close();
	}
    static class Scanner {

        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int curbuf;
        private int lenbuf;

        public Scanner(InputStream in) {
            this.in = in;
            this.curbuf = this.lenbuf = 0;
        }

        public boolean hasNextByte() {
            if (curbuf >= lenbuf) {
                curbuf = 0;
                try {
                    lenbuf = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0)
                    return false;
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[curbuf++];
            else
                return -1;
        }

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

        private void skip() {
            while (hasNextByte() && isSpaceChar(buffer[curbuf]))
                curbuf++;
        }

        public boolean hasNext() {
            skip();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (!isSpaceChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

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

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

    }

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	public static long GCD(long a, long b) {
		if (b == 0)
			return a;
		if (a == 0)
			return b;
		return (a > b) ? GCD(a % b, b) : GCD(a, b % a);
	}

	public static long LCM(long a, long b) {
		return a * b / GCD(a, b);
	}

	static long Pow(long a, long e, int mod) // O(log e)
	{
		a %= mod;
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static long nc(int n, int r) {
		if (n < r)
			return 0;
		long v = fac[n];
		v *= Pow(fac[r], mod - 2, mod);
		v %= mod;
		v *= Pow(fac[n - r], mod - 2, mod);
		v %= mod;
		return v;
	}

	public static boolean isprime(long a) {
		if (a == 0 || a == 1) {
			return false;
		}
		if (a == 2) {
			return true;
		}
		for (int i = 2; i < Math.sqrt(a) + 1; i++) {
			if (a % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static boolean isPal(String s) {
		boolean t = true;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				t = false;
				break;
			}
		}
		return t;
	}

	public static long RandomPick(long[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static int RandomPick(int[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static void PH(String s, boolean reverse) {
		prelen = s.length();
		HashsArray[HashsArrayInd] = new int[prelen + 1];
		prepow = new int[prelen];
		if (HashsArrayInd == 0) {
			int[] mods = { 1173017693, 1173038827, 1173069731, 1173086977, 1173089783, 1173092147, 1173107093,
					1173114391, 1173132347, 1173144367, 1173150103, 1173152611, 1173163993, 1173174127, 1173204679,
					1173237343, 1173252107, 1173253331, 1173255653, 1173260183, 1173262943, 1173265439, 1173279091,
					1173285331, 1173286771, 1173288593, 1173298123, 1173302129, 1173308827, 1173310451, 1173312383,
					1173313571, 1173324371, 1173361529, 1173385729, 1173387217, 1173387361, 1173420799, 1173421499,
					1173423077, 1173428083, 1173442159, 1173445549, 1173451681, 1173453299, 1173454729, 1173458401,
					1173459491, 1173464177, 1173468943, 1173470041, 1173477947, 1173500677, 1173507869, 1173522919,
					1173537359, 1173605003, 1173610253, 1173632671, 1173653623, 1173665447, 1173675577, 1173675787,
					1173684683, 1173691109, 1173696907, 1173705257, 1173705523, 1173725389, 1173727601, 1173741953,
					1173747577, 1173751499, 1173759449, 1173760943, 1173761429, 1173762509, 1173769939, 1173771233,
					1173778937, 1173784637, 1173793289, 1173799607, 1173802823, 1173808003, 1173810919, 1173818311,
					1173819293, 1173828167, 1173846677, 1173848941, 1173853249, 1173858341, 1173891613, 1173894053,
					1173908039, 1173909203, 1173961541, 1173968989, 1173999193 };
			mod = RandomPick(mods);
			int[] primes = { 59, 61, 67, 71, 73, 79, 83, 89, 97, 101 };
			prime = RandomPick(primes);
		}
		prepow[0] = 1;
		if (!reverse) {

			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
			}

		} else {
			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[prelen - 1 - i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);

			}

		}

		HashsArrayInd++;

	}

	public static int PHV(int l, int r, int n, boolean reverse) {
		if (l > r) {
			return 0;
		}
		int val = (int) ((1l * HashsArray[n - 1][r] + mod - HashsArray[n - 1][l - 1]) % mod);
		if (!reverse) {

			val = (int) ((1l * val * prepow[prelen - l]) % mod);
		} else {
			val = (int) ((1l * val * prepow[r - 1]) % mod);
		}
		return val;
	}
	 static int modInverse(long a, int m)
	    {
	        a = a % m;
	        for (int x = 1; x < m; x++)
	           if ((a * x) % m == 1)
	              return x;
	        return 1;
	    }
	static int[][] HashsArray;
	static int HashsArrayInd = 0;
	static int[] prepow;
	static int prelen = 0;
	static int prime = 31;
	static long fac[];
	static int mod = 998244353;
	static Random rn = new Random();
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);
}

import java.util.*;
import java.io.*;
import java.security.acl.Owner;

public class codeforces {

	public static void main(String[] args) throws Exception {
		long n=sc.nextLong();
		long m=sc.nextLong();
		long l=sc.nextLong();
		long r=sc.nextLong();
		long k=1l*r-l+1;
		long num=1l*n*m;
		long even=k/2;
		long odd=k/2;
		if(k%2==1) {
		if(l%2==1) {
			odd++;
		}else {
			even++;
		}

		}

		long ans=0;
		if(num%2==1) {
			ans=Pow(k, num, mod);
			pw.println(ans);
		}
		else {
			long a=Pow(odd, 2, mod);
			long b=Pow(even, 2, mod);
			if(odd>even) {
			ans=(((Pow(a, num/2+1, mod)-Pow(b, num/2+1, mod))%mod)*Pow(a-b, mod - 2, mod))%mod;
			}else if(odd<even) {
				ans=(((Pow(b, num/2+1, mod)-Pow(a, num/2+1, mod))%mod)*Pow(b-a, mod - 2, mod))%mod;
			}else {
				ans=(Pow(odd, num, mod)*(num/2+1))%mod;
			}
			pw.println(ans);
		}

		pw.close();
	}
    static class Scanner {

        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int curbuf;
        private int lenbuf;

        public Scanner(InputStream in) {
            this.in = in;
            this.curbuf = this.lenbuf = 0;
        }

        public boolean hasNextByte() {
            if (curbuf >= lenbuf) {
                curbuf = 0;
                try {
                    lenbuf = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0)
                    return false;
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[curbuf++];
            else
                return -1;
        }

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

        private void skip() {
            while (hasNextByte() && isSpaceChar(buffer[curbuf]))
                curbuf++;
        }

        public boolean hasNext() {
            skip();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (!isSpaceChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            int c = readByte();
            while (isSpaceChar(c))
                c = readByte();
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res = res * 10 + c - '0';
                c = readByte();
            } while (!isSpaceChar(c));
            return (minus) ? -res : res;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

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

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

    }

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	public static long GCD(long a, long b) {
		if (b == 0)
			return a;
		if (a == 0)
			return b;
		return (a > b) ? GCD(a % b, b) : GCD(a, b % a);
	}

	public static long LCM(long a, long b) {
		return a * b / GCD(a, b);
	}

	static long Pow(long a, long e, int mod) // O(log e)
	{
		a %= mod;
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static long nc(int n, int r) {
		if (n < r)
			return 0;
		long v = fac[n];
		v *= Pow(fac[r], mod - 2, mod);
		v %= mod;
		v *= Pow(fac[n - r], mod - 2, mod);
		v %= mod;
		return v;
	}

	public static boolean isprime(long a) {
		if (a == 0 || a == 1) {
			return false;
		}
		if (a == 2) {
			return true;
		}
		for (int i = 2; i < Math.sqrt(a) + 1; i++) {
			if (a % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static boolean isPal(String s) {
		boolean t = true;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				t = false;
				break;
			}
		}
		return t;
	}

	public static long RandomPick(long[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static int RandomPick(int[] a) {
		int n = a.length;
		int r = rn.nextInt(n);
		return a[r];
	}

	public static void PH(String s, boolean reverse) {
		prelen = s.length();
		HashsArray[HashsArrayInd] = new int[prelen + 1];
		prepow = new int[prelen];
		if (HashsArrayInd == 0) {
			int[] mods = { 1173017693, 1173038827, 1173069731, 1173086977, 1173089783, 1173092147, 1173107093,
					1173114391, 1173132347, 1173144367, 1173150103, 1173152611, 1173163993, 1173174127, 1173204679,
					1173237343, 1173252107, 1173253331, 1173255653, 1173260183, 1173262943, 1173265439, 1173279091,
					1173285331, 1173286771, 1173288593, 1173298123, 1173302129, 1173308827, 1173310451, 1173312383,
					1173313571, 1173324371, 1173361529, 1173385729, 1173387217, 1173387361, 1173420799, 1173421499,
					1173423077, 1173428083, 1173442159, 1173445549, 1173451681, 1173453299, 1173454729, 1173458401,
					1173459491, 1173464177, 1173468943, 1173470041, 1173477947, 1173500677, 1173507869, 1173522919,
					1173537359, 1173605003, 1173610253, 1173632671, 1173653623, 1173665447, 1173675577, 1173675787,
					1173684683, 1173691109, 1173696907, 1173705257, 1173705523, 1173725389, 1173727601, 1173741953,
					1173747577, 1173751499, 1173759449, 1173760943, 1173761429, 1173762509, 1173769939, 1173771233,
					1173778937, 1173784637, 1173793289, 1173799607, 1173802823, 1173808003, 1173810919, 1173818311,
					1173819293, 1173828167, 1173846677, 1173848941, 1173853249, 1173858341, 1173891613, 1173894053,
					1173908039, 1173909203, 1173961541, 1173968989, 1173999193 };
			mod = RandomPick(mods);
			int[] primes = { 59, 61, 67, 71, 73, 79, 83, 89, 97, 101 };
			prime = RandomPick(primes);
		}
		prepow[0] = 1;
		if (!reverse) {

			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
			}

		} else {
			for (int i = 1; i < prelen; i++) {
				prepow[i] = (int) ((1l * prepow[i - 1] * prime) % mod);

			}
			for (int i = 0; i < prelen; i++) {
				if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'a' + 1) * prepow[prelen - 1 - i]) % mod) % mod);
				else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - 'A' + 27) * prepow[prelen - 1 - i]) % mod) % mod);
				else
					HashsArray[HashsArrayInd][i + 1] = (int) ((1l * HashsArray[HashsArrayInd][i]
							+ ((1l * s.charAt(i) - '0' + 1) * prepow[prelen - 1 - i]) % mod) % mod);

			}

		}

		HashsArrayInd++;

	}

	public static int PHV(int l, int r, int n, boolean reverse) {
		if (l > r) {
			return 0;
		}
		int val = (int) ((1l * HashsArray[n - 1][r] + mod - HashsArray[n - 1][l - 1]) % mod);
		if (!reverse) {

			val = (int) ((1l * val * prepow[prelen - l]) % mod);
		} else {
			val = (int) ((1l * val * prepow[r - 1]) % mod);
		}
		return val;
	}
	 static int modInverse(long a, int m)
	    {
	        a = a % m;
	        for (int x = 1; x < m; x++)
	           if ((a * x) % m == 1)
	              return x;
	        return 1;
	    }
	static int[][] HashsArray;
	static int HashsArrayInd = 0;
	static int[] prepow;
	static int prelen = 0;
	static int prime = 31;
	static long fac[];
	static int mod = 998244353;
	static Random rn = new Random();
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {

    static int mod = 998_244_353;
    static long pow(long a,long n) {
        long res=1;
        while (n>0) {
            if ((n-n/2*2)==1) {
                res=res*a%mod;
            }
            a=a*a%mod;
            n>>=1;
        }
        return res;
    }

    static long modinv(long n) {
        return pow(n, mod-2);
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        long n = in.nextLong();
        long m = in.nextLong();
        long L = in.nextLong();
        long R = in.nextLong();
        if (n*m%2==1) {
            out.println(pow(R-L+1, n*m));
        } else { // n*m%2==0
            long tmp = pow(R-L+1, n*m);
            if ((R-L+1)%2==1) tmp=(tmp+1)%mod;
            out.println(tmp*modinv(2)%mod);
        }
        out.println(modinv(2));

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {

    static int mod = 998_244_353;
    static long pow(long a,long n) {
        long res=1;
        while (n>0) {
            if ((n-n/2*2)==1) {
                res=res*a%mod;
            }
            a=a*a%mod;
            n>>=1;
        }
        return res;
    }

    static long modinv(long n) {
        return pow(n, mod-2);
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        long n = in.nextInt();
        long m = in.nextInt();
        long L = in.nextInt();
        long R = in.nextInt();
        if (n*m%2==1) {
            out.println(pow(R-L+1, n*m));
        } else { // n*m%2==0
            long tmp = pow(R-L+1, n*m);
            if (tmp%2==1) tmp++;
            out.println(tmp*modinv(2)%mod);
        }

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {

    static int mod = 998_244_353;
    static long pow(long a,long n) {
        long res=1;
        while (n>0) {
            if ((n-n/2*2)==1) {
                res=res*a%mod;
            }
            a=a*a%mod;
            n>>=1;
        }
        return res;
    }

    static long modinv(long n) {
        return pow(n, mod-2);
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        long n = in.nextLong();
        long m = in.nextLong();
        long L = in.nextLong();
        long R = in.nextLong();
        if (n*m%2==1) {
            out.println(pow(R-L+1, n*m));
        } else { // n*m%2==0
            long tmp = pow(R-L+1, n*m);
            if (tmp%2==1) tmp=(tmp+1)%mod;
            out.println(tmp*modinv(2)%mod);
        }

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}

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

public class tr0 {
	static PrintWriter out;
	static StringBuilder sb;
	static long mod = 998244353;
	static int inf = (int) 1e15;
	static ArrayList<Integer>[] ad;
	static int n, r, m;
	static int[][] memo, grid;
	static char[][] g;
	static boolean[] vis;
	static long ans, tem;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		long n = sc.nextInt();
		long m = sc.nextInt();
		long l = sc.nextInt();
		long r = sc.nextInt();
		long all = modPow(r - l + 1, n * m);
		long od = ((r + 1) / 2) - (l / 2);
		long ev = (r / 2) - ((l - 1) / 2);
		long d2 = (modPow((od + ev) % mod, n * m) - modPow(od, n * m) + mod) % mod;
		d2 = (d2 - modPow(ev, n * m) + mod) % mod;
		System.out.println((all - d2 + mod) % mod);
		out.close();
	}

	static long modPow(long a, long e)

	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

public class tr0 {
	static PrintWriter out;
	static StringBuilder sb;
	static long mod = 998244353;
	static int inf = (int) 1e15;
	static ArrayList<Integer>[] ad;
	static int n, r, m;
	static int[][] memo, grid;
	static char[][] g;
	static boolean[] vis;
	static long ans, tem;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		long n = sc.nextInt();
		long m = sc.nextInt();
		long l = sc.nextInt();
		long r = sc.nextInt();
		long all = modPow(r - l + 1, n * m);
		// long diff = (modPow(2, n * m) - 2 + mod) % mod;
		long od = ((r + 1) / 2) - ((l) / 2);
		long ev = (r / 2) - ((l - 1) / 2);
		// diff = (diff * od + diff * ev) % mod;
	//	System.out.println(od+" "+ev+" "+all);
		long d2 = (modPow(od + ev, n * m) - modPow(od, n * m) + mod) % mod;
		d2 = (d2 - modPow(ev, n * m) + mod) % mod;
		System.out.println((all - d2 + mod) % mod);
		out.close();
	}

	static long modPow(long a, long e)

	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

public class e{

	static long mod = 998224353;

	public static void main(String[] args){
		JS scan = new JS();
		long n = scan.nextLong();
		long m = scan.nextLong();
		long L = scan.nextLong();
		long R = scan.nextLong();
		long h = R-L;

		long e = 0;
		long o = 0;
		if(h % 2 == 1){
			long d = (h+1)/2;
			e = d;
			o = d;
		}
		else{
			long d = h/2;
			e = d;
			o = d;
			if(L % 2 == 1) o++;
			else e++;
		}

		long[][] mat = {{e, o},{o, e}};
		long[][] pphard = pow(mat, m*n);
		long ans = pphard[0][0];
		if((n*m)%2==1) ans += pphard[0][1];
		System.out.println(ans);
	}

	static long[][] pow(long[][] a, long pow){
		if(pow == 0) return iden(a.length);
		if(pow % 2 == 1){
			long[][] res = pow(a, pow-1);
			return mult(res, a);
		}
		long[][] res = pow(a, pow/2);
		return mult(res, res);
	}

	static long[][] iden(int n){
		long[][] res = new long[n][n];
		for(int i = 0; i < n; i++) res[i][i] = 1;
		return res;
	}

	static long[][] mult(long[][] a, long[][] b){
		long[][] res = new long[a.length][b[0].length];
		for(int i = 0; i < a.length; i++){
			for(int j = 0; j < b[0].length; j++){
				for(int k = 0; k < a[0].length; k++){
					res[i][j] += a[i][k]*b[k][j];
					res[i][j] %= mod;
				}
			}
		}
		return res;
	}

	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}

}

import java.util.Scanner;

public class a {
    static long mod = 998244353;

    static long fpow(long x, long n) {
        long res = 1;
        x %= mod;
        while (n > 0) {
            if ((n & 1) == 1)
                res = res * x % mod;
            x = x * x % mod;
            n >>= 1;
        }
        return res;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        long m = in.nextInt();
        long L = in.nextInt();
        long R = in.nextInt();
        long ans = fpow(R - L + 1, n * m);
        if ((n * m) % 2 == 1) {
            System.out.println(ans);
        } else {
            if ((ans % 2) == 0)
                ans /= 2;
            else {
                ans /= 2;
                ans++;
            }
            System.out.println(ans);
        }
        in.close();
    }
}

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

public class HeightAllTheSame {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(in.readLine());
		int N = Integer.parseInt(st.nextToken());
		int M = Integer.parseInt(st.nextToken());
		int L = Integer.parseInt(st.nextToken());
		int R = Integer.parseInt(st.nextToken());
		if((N * M) % 2 == 1) {
			out.println(pow(R - L + 1, N * M));
		} else if((R - L + 1) % 2 == 0) {
			out.println(pow(R - L + 1, N * M) * (998244353 + 1) / 2 % 998244353);
		} else {
			out.println((pow(R - L + 1, N * M) + 1) * (998244353 + 1) / 2 % 998244353);
		}
		in.close();
		out.close();
	}
	static long pow(long a, long b) {
		long res = 1;
		while(b > 0) {
			if(b % 2 == 1) {
				res = (res * a) % 998244353;
				b--;
			}
			a = (a * a) % 998244353;
			b /= 2;
		}
		return res;
	}
}

/*****Author: Satyajeet Singh, Delhi Technological University************************************/
    import java.io.*;
    import java.util.*;
    import java.text.*;
    import java.lang.*;
    import java.math.*;
public class Main{
/*********************************************Constants******************************************/
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static long mod=(long)1e9+7;
    static long mod1=998244353;
    static HashSet<Integer> graph[];
    static int pptr=0,pptrmax=0;
    static String st[];
/*****************************************Solutions Begins***************************************/
    public static void main(String args[]) throws Exception{
        long n=pl();
        long m=pl();
        long l=pl();
        long r=pl();
        long d=r-l+1;
        long a=d/2;
        long b=d-a;
        long nm=n*m;
        mod=mod1;
        //debug(a,b);

        long ans=(modulo((a+b),nm,mod)+modulo(Math.abs(a-b),nm,mod))%mod;
        if(nm%2==1){
            ans=(modulo(a,nm,mod)+modulo(b,nm,mod))%mod;
        }
        ans=(ans*modulo(2l,mod-2,mod))%mod;
        out.println(ans);
/****************************************Solutions Ends**************************************************/
        out.flush();
        out.close();
    }
/****************************************Template Begins************************************************/
    static void nl() throws Exception{
        pptr=0;
        st=br.readLine().split(" ");
        pptrmax=st.length;
    }
    static void nls() throws Exception{
        pptr=0;
        st=br.readLine().split("");
        pptrmax=st.length;
    }
    static int pi() throws Exception{
        if(pptr==pptrmax)
            nl();
        return Integer.parseInt(st[pptr++]);
    }
    static long pl() throws Exception{
        if(pptr==pptrmax)
            nl();
        return Long.parseLong(st[pptr++]);
    }
    static double pd() throws Exception{
        if(pptr==pptrmax)
            nl();
        return Double.parseDouble(st[pptr++]);
    }
    static String ps() throws Exception{
        if(pptr==pptrmax)
            nl();
        return st[pptr++];
    }
/***************************************Precision Printing**********************************************/
    static void printPrecision(double d){
        DecimalFormat ft = new DecimalFormat("0.000000000000");
        out.print(ft.format(d));
    }
/**************************************Bit Manipulation**************************************************/
    static void printMask(long mask){
        System.out.println(Long.toBinaryString(mask));
    }
    static int countBit(long mask){
        int ans=0;
        while(mask!=0){
            mask&=(mask-1);
            ans++;
        }
        return ans;
    }
/******************************************Graph*********************************************************/
    static void Makegraph(int n){
        graph=new HashSet[n];
        for(int i=0;i<n;i++){
            graph[i]=new HashSet<>();
        }
    }
    static void addEdge(int a,int b){
        graph[a].add(b);
    }
    // static void addEdge(int a,int b,int c){
    //     graph[a].add(new Pair(b,c));
    // }
/*********************************************PAIR********************************************************/
    static class Pair implements Comparable<Pair> {
        int u;
        int v;
        int index=-1;
        public Pair(int u, int v) {
            this.u = u;
            this.v = v;
        }
        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return 31 * hu + hv;
        }
        public boolean equals(Object o) {
            Pair other = (Pair) o;
            return u == other.u && v == other.v;
        }
        public int compareTo(Pair other) {
            if(index!=other.index)
                return Long.compare(index, other.index);
            return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
        }
        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }
    }
/******************************************Long Pair*******************************************************/
    static class Pairl implements Comparable<Pairl> {
            long u;
            long v;
            int index=-1;
            public Pairl(long u, long v) {
                this.u = u;
                this.v = v;
            }
            public int hashCode() {
                int hu = (int) (u ^ (u >>> 32));
                int hv = (int) (v ^ (v >>> 32));
                return 31 * hu + hv;
            }
            public boolean equals(Object o) {
                Pairl other = (Pairl) o;
                return u == other.u && v == other.v;
            }
            public int compareTo(Pairl other) {
                if(index!=other.index)
                    return Long.compare(index, other.index);
                return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
            }
            public String toString() {
                return "[u=" + u + ", v=" + v + "]";
            }
        }
/*****************************************DEBUG***********************************************************/
    public static void debug(Object... o){
        System.out.println(Arrays.deepToString(o));
    }
/************************************MODULAR EXPONENTIATION***********************************************/
    static long modulo(long a,long b,long c){
        long x=1;
        long y=a%c;
        while(b > 0){
            if(b%2 == 1)
                x=(x*y)%c;
            y = (y*y)%c;
            b /= 2;
        }
        return  x%c;
    }
/********************************************GCD**********************************************************/
    static long gcd(long x, long y){
        if(x==0)
            return y;
        if(y==0)
            return x;
        long r=0, a, b;
        a = (x > y) ? x : y;
        b = (x < y) ? x : y;
        r = b;
        while(a % b != 0){
            r = a % b;
            a = b;
            b = r;
        }
        return r;
    }
/********************************************End***********************************************************/
}

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long M = Long.parseLong(st.nextToken());
         long L = Long.parseLong(st.nextToken());
         long R = Long.parseLong(st.nextToken());
         //fuck Bob
         if((N*M)%2 == 1)
         {
            long temp = N*M;
            //temp %= MOD;
            long res = power(R-L+1, temp, MOD);
            System.out.println(res);
         }
         else
         {
            //even # of odd columns
            long col = (N*M);
            long odd = R/2;
            if(R%2 == 1)
               odd++;
            odd -= (L-1)/2;
            if((L-1)%2 == 1)
               odd--;
            long even = R-L+1-odd;
            odd %= MOD;
            even %= MOD;
            long exp = (col*power(2, MOD-2, MOD))%MOD;
            //long exp = col;
            odd = (odd*odd)%MOD;
            even = (even*even)%MOD;
            long base = (odd+even)%MOD;
            long res = power(base, exp, MOD);
            System.out.println(res);
         }
      }
      public static long power(long x, long y, long p)
      {
          long res = 1L;
          x = x % p;
          while (y > 0)
          {
              if((y & 1)==1)
                  res = (res * x) % p;
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
   }

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long M = Long.parseLong(st.nextToken());
         long L = Long.parseLong(st.nextToken());
         long R = Long.parseLong(st.nextToken());
         //dont panic
         //that makes you lose Omkar energy
         long temp = N*M;
         long res = power(R-L+1, temp, 2*MOD);
         //res += MOD;
         if((N%M)%2 == 1)
            res = (res+1)/2;
         System.out.println(res%MOD);
      }
      public static long power(long x, long y, long p)
      {
          long res = 1L;
          x = x % p;
          while (y > 0)
          {
              if((y & 1)==1)
                  res = (res * x) % p;
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
   }

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E2
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long M = Long.parseLong(st.nextToken());
         long L = Long.parseLong(st.nextToken());
         long R = Long.parseLong(st.nextToken());
         //fuck Bob
         if((N*M)%2 == 1)
         {
            long temp = N*M;
            BigInteger exp = new BigInteger(temp+"");
            BigInteger base = new BigInteger((R-L+1)+"");
            BigInteger mod = new BigInteger(MOD+"");
            long res = base.modPow(exp, mod).longValue();
            System.out.println((res+MOD)%MOD);
         }
         else
         {
            //even # of odd columns
            long col = (N*M);

            long odd = (R-L)/2;
            if(R%2 != 0 || L%2 != 0)
               odd++;
            long even = R-L+1-odd;
            odd %= MOD;
            even %= MOD;
            odd = (odd*odd)%MOD;
            even = (even*even)%MOD;

            //find exp
            col /= 2;
            BigInteger exp = new BigInteger(col+"");
            //exp.multiply(new BigInteger(power(2,MOD-2,MOD)+""));

            long temp = (odd+even)%MOD;
            BigInteger base = new BigInteger(temp+"");
            BigInteger mod = new BigInteger(MOD+"");

            BigInteger res = base.modPow(exp, mod);
            System.out.println((res.longValue()+MOD)%MOD);
         }
      }
      public static long power(long x, long y, long p)
      {
          long res = 1L;
          x = x % p;
          while (y > 0)
          {
              if((y & 1)==1)
                  res = (res * x) % p;
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
   }

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E2
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long M = Long.parseLong(st.nextToken());
         long L = Long.parseLong(st.nextToken());
         long R = Long.parseLong(st.nextToken());
         if((N*M)%2 == 1)
         {
            //here?
            long temp = N*M;
            BigInteger exp = new BigInteger(temp+"");
            BigInteger base = new BigInteger((R-L+1)+"");
            BigInteger mod = new BigInteger(MOD+"");
            long res = base.modPow(exp, mod).longValue();
            if((N*M)%4 != 0)
            res = (res*power(2, MOD-2,MOD))%MOD;
            System.out.println((res+MOD)%MOD);
         }
         else
         {
            //even # of odd columns
            long col = (N*M);

            long odd = (R-L)/2;
            if(R%2 != 0 || L%2 != 0)
               odd++;
            long even = R-L+1-odd;
            odd = (odd*odd)%MOD;
            even = (even*even)%MOD;

            //find exp
            col /= 2;
            BigInteger exp = new BigInteger(col+"");
            //exp.multiply(new BigInteger(power(2,MOD-2,MOD)+""));

            long temp = (odd+even)%MOD;
            BigInteger base = new BigInteger(temp+"");
            BigInteger mod = new BigInteger(MOD+"");

            BigInteger res = base.modPow(exp, mod);
            System.out.println((res.longValue()+MOD)%MOD);
         }
      }
      public static long power(long x, long y, long p)
      {
          long res = 1L;
          x = x % p;
          while (y > 0)
          {
              if((y & 1)==1)
                  res = (res * x) % p;
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
   }

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E2
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long M = Long.parseLong(st.nextToken());
         long L = Long.parseLong(st.nextToken());
         long R = Long.parseLong(st.nextToken());
         if((N*M)%2 == 1)
         {
            //here?
            long temp = N*M;
            BigInteger exp = new BigInteger(temp+"");
            BigInteger base = new BigInteger((R-L+1)+"");
            BigInteger mod = new BigInteger(MOD+"");
            long res = base.modPow(exp, mod).longValue();
            System.out.println((res+MOD)%MOD);
         }
         else
         {
            //even # of odd columns
            long col = (N*M);

            long odd = (R-L)/2;
            if(R%2 != 0 || L%2 != 0)
               odd++;
            long even = R-L+1-odd;
            odd = (odd*odd)%MOD;
            even = (even*even)%MOD;

            //find exp
            col /= 2;
            BigInteger exp = new BigInteger(col+"");
            //exp.multiply(new BigInteger(power(2,MOD-2,MOD)+""));

            long temp = (odd+even)%MOD;
            BigInteger base = new BigInteger(temp+"");
            BigInteger mod = new BigInteger(MOD+"");

            BigInteger res = base.modPow(exp, mod);
            System.out.println((res.longValue()+MOD)%MOD);
         }
      }
      public static long power(long x, long y, long p)
      {
          long res = 1L;
          x = x % p;
          while (y > 0)
          {
              if((y & 1)==1)
                  res = (res * x) % p;
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
   }

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long M = Long.parseLong(st.nextToken());
         long L = Long.parseLong(st.nextToken());
         long R = Long.parseLong(st.nextToken());
         //fuck Bob
         if((N*M)%2 == 1)
         {
            long temp = N*M;
            temp %= MOD;
            long res = power(R-L+1, temp, MOD);
            System.out.println(res);
         }
         else
         {
            //even # of odd columns
            long col = (N*M)%MOD;
            long odd = R/2;
            if(R%2 == 1)
               odd++;
            odd -= (L-1)/2;
            if((L-1)%2 == 1)
               odd--;
            long even = R-L+1-odd;
            odd %= MOD;
            even %= MOD;
            long exp = (col*power(2, MOD-2, MOD))%MOD;
            odd = (odd*odd)%MOD;
            even = (even*even)%MOD;
            long base = (odd+even)%MOD;
            long res = power(base, exp, MOD);
            System.out.println(res);
         }
      }
      public static long power(long x, long y, long p)
      {
          long res = 1L;
          x = x % p;
          while (y > 0)
          {
              if((y & 1)==1)
                  res = (res * x) % p;
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
   }

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E2
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long M = Long.parseLong(st.nextToken());
         long L = Long.parseLong(st.nextToken());
         long R = Long.parseLong(st.nextToken());
         //fuck Bob
         if((N*M)%2 == 1)
         {
            long temp = N*M;
            long res = power(R-L+1, temp, MOD);
            System.out.println(res);
         }
         else
         {
            //even # of odd columns
            long col = (N*M);

            long odd = (R-L)/2;
            if(R%2 != 0 || L%2 != 0)
               odd++;
            long even = R-L+1-odd;
            odd %= MOD;
            even %= MOD;
            odd = (odd*odd)%MOD;
            even = (even*even)%MOD;

            //find exp
            col /= 2;
            BigInteger exp = new BigInteger(col+"");
            //exp.multiply(new BigInteger(power(2,MOD-2,MOD)+""));

            long temp = (odd+even)%MOD;
            BigInteger base = new BigInteger(temp+"");
            BigInteger mod = new BigInteger(MOD+"");

            BigInteger res = base.modPow(exp, mod);
            System.out.println(res.longValue());
         }
      }
      public static long power(long x, long y, long p)
      {
          long res = 1L;
          x = x % p;
          while (y > 0)
          {
              if((y & 1)==1)
                  res = (res * x) % p;
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
   }

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E2
   {
      static long MOD = 998244353L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long M = Long.parseLong(st.nextToken());
         long L = Long.parseLong(st.nextToken());
         long R = Long.parseLong(st.nextToken());
         if((N*M)%2 == 1)
         {
            //here?
            long temp = N*M;
            BigInteger exp = new BigInteger(temp+"");
            BigInteger base = new BigInteger((R-L+1)+"");
            BigInteger mod = new BigInteger(MOD+"");
            long res = base.modPow(exp, mod).longValue();
            res = (res*power(2, MOD-2,MOD))%MOD;
            System.out.println((res+MOD)%MOD);
         }
         else
         {
            //even # of odd columns
            long col = (N*M);

            long odd = (R-L)/2;
            if(R%2 != 0 || L%2 != 0)
               odd++;
            long even = R-L+1-odd;
            odd = (odd*odd)%MOD;
            even = (even*even)%MOD;

            //find exp
            col /= 2;
            BigInteger exp = new BigInteger(col+"");
            //exp.multiply(new BigInteger(power(2,MOD-2,MOD)+""));

            long temp = (odd+even)%MOD;
            BigInteger base = new BigInteger(temp+"");
            BigInteger mod = new BigInteger(MOD+"");

            BigInteger res = base.modPow(exp, mod);
            System.out.println((res.longValue()+MOD)%MOD);
         }
      }
      public static long power(long x, long y, long p)
      {
          long res = 1L;
          x = x % p;
          while (y > 0)
          {
              if((y & 1)==1)
                  res = (res * x) % p;
              y = y >> 1;
              x = (x * x) % p;
          }
          return res;
      }
   }