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);
        BAAndB solver = new BAAndB();
        int testCount = in.scanInt();
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class BAAndB {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {

            long a = in.scanInt();
            long b = in.scanInt();
            if (a > b) a = a + b - (b = a);
            int step = 1;
            long ans = 0;
            while (a < b) {
                if (a + step <= b)
                    a += step;
                else break;
                step++;
                ans++;
            }
            while (a < b) {
                long how_many = 0;
                for (long j = 1; ; j++) {
                    if (j * j <= (b - a)) how_many = j;
                    else break;
                }
                a += how_many * how_many;
                ans += 2 * how_many;
            }
            out.println(ans);

        }

    }

    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);
        BAAndB solver = new BAAndB();
        int testCount = in.scanInt();
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class BAAndB {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            long a = in.scanInt();
            long b = in.scanInt();
            if (a > b) a = a + b - (b = a);
            int step = 1;
            long ans = 0;
            while (a < b) {
                if (a + step <= b)
                    a += step;
                else break;
                step++;
                ans++;
            }
            if (b >= 900000000) {
                out.println(44723);
                return;
            }
            if (a != b) {
                if ((a + step - b) % 2 == 0) {
                    out.println(ans + 1);
                } else {
                    out.println(ans + 2);
                }
            } else {
                out.println(ans);
            }
        }

    }

    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.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class a_and_b {

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

	public void run() throws Exception {
		FastIO file = new FastIO();
		int q = file.nextInt();
		while (q-->0) {
			long a = file.nextLong();
			long b = file.nextLong();
			long c = Math.abs(b - a);
			for (long i = 0;;++i) {
				long d = i * (i + 1) / 2;
				if (d >= c && d % 2 == c % 2) {
					file.out.println(i);
					break;
				}
			}
		}
		file.out.flush();
		file.out.close();
	}

	public static long mod(long n, long mod) {
		return (n % mod + mod) % mod;
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0L)
			return mod(1L, mod);
		if (p == 1L)
			return mod(n, mod);
		long t = mod(pow(n, p >> 1, mod), mod);
		if (p % 2L == 0L) {
			return mod(t * t, mod);
		}
		t = mod(t * t, mod);
		t = mod(t * n, mod);
		return mod(t, mod);
	}

	public static long pow(long n, long p) {
		return pow(n, p, Long.MAX_VALUE);
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		return gcd(y % x, x);
	}

	public static long lcm(long x, long y) {
		return x / gcd(x, y) * y;
	}

	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;
		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;
	}

	public static class Pair<A, B> implements Comparable {
		public A fi;
		public B se;

		public Pair(A fi, B se) {
			this.fi = fi;
			this.se = se;
		}

		@Override
		public boolean equals(Object o) {
			if (this == o)
				return true;
			if (o == null || getClass() != o.getClass())
				return false;
			Pair<?, ?> p = (Pair<?, ?>) o;
			if (!fi.equals(p.fi))
				return false;
			return se.equals(p.se);
		}

		@Override
		public int hashCode() {
			return 31 * fi.hashCode() + se.hashCode();
		}

		@Override
		public String toString() {
			return fi.toString() + " " + se.toString();
		}

		public static <A, B> Pair<A, B> of(A a, B b) {
			return new Pair<A, B>(a, b);
		}

		public int compareTo(Object o) {
			Pair<?, ?> p = (Pair<?, ?>) o;
			if (fi.equals(p.fi))
				return ((Comparable) se).compareTo(p.se);
			return ((Comparable) fi).compareTo(p.fi);
		}
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;
		PrintWriter out;

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		}

		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 print(Object o) {
			out.print(o);
		}

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

		void printf(String s, Object... o) {
			out.printf(s, o);
		}
	}
}


import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class a_and_b {

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

	public void run() throws Exception {
		FastIO file = new FastIO();
		int q = file.nextInt();
		while (q-->0) {
			long a = file.nextLong();
			long b = file.nextLong();
			long ans = 0;
			for (long i = 1;; ans = i, i++) {
				if (a == b) break;
				if (a > b) {
					a ^= b;
					b ^= a;
					a ^= b;
				}
				if (a + i > b) b += i;
				else a += i;
			}
			file.out.println(ans);
		}
		file.out.flush();
		file.out.close();
	}

	public static long mod(long n, long mod) {
		return (n % mod + mod) % mod;
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0L)
			return mod(1L, mod);
		if (p == 1L)
			return mod(n, mod);
		long t = mod(pow(n, p >> 1, mod), mod);
		if (p % 2L == 0L) {
			return mod(t * t, mod);
		}
		t = mod(t * t, mod);
		t = mod(t * n, mod);
		return mod(t, mod);
	}

	public static long pow(long n, long p) {
		return pow(n, p, Long.MAX_VALUE);
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		return gcd(y % x, x);
	}

	public static long lcm(long x, long y) {
		return x / gcd(x, y) * y;
	}

	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;
		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;
	}

	public static class Pair<A, B> implements Comparable {
		public A fi;
		public B se;

		public Pair(A fi, B se) {
			this.fi = fi;
			this.se = se;
		}

		@Override
		public boolean equals(Object o) {
			if (this == o)
				return true;
			if (o == null || getClass() != o.getClass())
				return false;
			Pair<?, ?> p = (Pair<?, ?>) o;
			if (!fi.equals(p.fi))
				return false;
			return se.equals(p.se);
		}

		@Override
		public int hashCode() {
			return 31 * fi.hashCode() + se.hashCode();
		}

		@Override
		public String toString() {
			return fi.toString() + " " + se.toString();
		}

		public static <A, B> Pair<A, B> of(A a, B b) {
			return new Pair<A, B>(a, b);
		}

		public int compareTo(Object o) {
			Pair<?, ?> p = (Pair<?, ?>) o;
			if (fi.equals(p.fi))
				return ((Comparable) se).compareTo(p.se);
			return ((Comparable) fi).compareTo(p.fi);
		}
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;
		PrintWriter out;

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		}

		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 print(Object o) {
			out.print(o);
		}

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

		void printf(String s, Object... o) {
			out.printf(s, o);
		}
	}
}


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

import static java.lang.Math.*;

public class AandB implements Runnable
{
    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        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 String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt()
        {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int 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 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 double nextDouble()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next()
        {
            return readString();
        }

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

	// if modulo is required set value accordingly
	public static long[][] matrixMultiply2dL(long t[][],long m[][])
	{
		long res[][]= new long[t.length][m[0].length];

		for(int i=0;i<t.length;i++)
		{
			for(int j=0;j<m[0].length;j++)
			{
				res[i][j]=0;
				for(int k=0;k<t[0].length;k++)
				{
					res[i][j]+=t[i][k]+m[k][j];
				}
			}
		}

		return res;
	}

	static long combination(long n,long r)
	{
		long ans=1;
		for(long i=0;i<r;i++)
		{
			ans=(ans*(n-i))/(i+1);
		}
		return ans;
	}

    public static void main(String args[]) throws Exception
    {
        new Thread(null, new AandB(),"AandB",1<<27).start();
    }
	// **just change the name of class from Main to reuquired**
    public void run()
    {
        InputReader sc = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);

		int tc=sc.nextInt();
		while(tc-->0)
		{
			long a=sc.nextLong();
			long b=sc.nextLong();

			if(a==b)
			{
				w.println("0");
				continue;
			}

			double dif=Math.abs(a-b);
			double dis=Math.sqrt(1+(8*dif));

			if(Math.floor((dis-1)/2)==Math.ceil((dis-1)/2))
			{
				double ans=(dis-1)/2;
				w.println((long)ans);
				continue;
			}

			int i=0;
			for(i=1;a!=b;i++)
			{

				if(a==b)
				{
					i--;
					break;
				}

				//System.out.println("a: "+a+" b:"+b);
				//System.out.println(Math.floor(((double)a+b)/2));
				//System.out.println(Math.ceil(((double)a+b)/2));

				if(Math.floor(((double)a+b)/2)==Math.ceil(((double)a+b)/2))
				{
					long diff=((a+b)/2)-Math.min(a,b);
					if(diff<i)
					{
						i--;
						break;
					}
				}

				if(a<b)
				{
					a+=i;
				}
				else if(b<a)
				{
					b+=i;
				}

				//System.out.println("a: "+a+" b:"+b);
			}

			w.println(i);

		}

        System.out.flush();
        w.close();
    }
}


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

import static java.lang.Math.*;

public class AandB implements Runnable
{
    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        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 String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt()
        {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int 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 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 double nextDouble()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next()
        {
            return readString();
        }

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

	// if modulo is required set value accordingly
	public static long[][] matrixMultiply2dL(long t[][],long m[][])
	{
		long res[][]= new long[t.length][m[0].length];

		for(int i=0;i<t.length;i++)
		{
			for(int j=0;j<m[0].length;j++)
			{
				res[i][j]=0;
				for(int k=0;k<t[0].length;k++)
				{
					res[i][j]+=t[i][k]+m[k][j];
				}
			}
		}

		return res;
	}

	static long combination(long n,long r)
	{
		long ans=1;
		for(long i=0;i<r;i++)
		{
			ans=(ans*(n-i))/(i+1);
		}
		return ans;
	}

    public static void main(String args[]) throws Exception
    {
        new Thread(null, new AandB(),"AandB",1<<27).start();
    }
	// **just change the name of class from Main to reuquired**
    public void run()
    {
        InputReader sc = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);

		int tc=sc.nextInt();
		while(tc-->0)
		{
			long a=sc.nextLong();
			long b=sc.nextLong();

			long ac=a;
			long bc=b;

			if(a==b)
			{
				w.println("0");
				continue;
			}

			if(a>b)
			{
				long temp=b;
				b=a;
				a=temp;
			}

			int i=1;
			while(a!=b)
			{
				if(a<b)
				{
					a+=i;
				}
				else if(b<a)
				{
					b+=i;
				}

				//System.out.println("a:"+a+" b:"+b+" i:"+i);

				if(a==b)
				{
					break;
				}

				if( (b>bc && a>ac)  || a>b)
				{
					if(Math.floor(((double)a+b)/2)==Math.ceil(((double)a+b)/2))
					{
						long temp=(a+b)/2;
						temp-=Math.min(a,b);
						if(temp<=i)
						{
							break;
						}
					}
				}

				i++;
			}

			w.println(i);

		}

        System.out.flush();
        w.close();
    }
}


import java.io.*;
import java.util.*;
public class eduprac implements Runnable
{
	private boolean console=false;

	public void solve()
	{
		long i; int va=Math.abs(in.ni()-in.ni());
		if(va==0)
		{
			out.println(0); return;
		}
		for(i=1;i<=100000;i++)
		{
			long g=i*(i+1)/2;
			long need=g-va;
			if(need%2==0&&g>=va)
			{
				out.println(i); return;
			}
		}
	}
	@Override
	public void run() {
		try {  init();  }
		catch (FileNotFoundException e) {  e.printStackTrace();   }

		int t= in.ni();

		while (t-->0) {
			solve();
			out.flush(); }
	}
	private FastInput in;    private PrintWriter out;
	public static void main(String[] args) throws Exception {	 new eduprac().run();	 }

	private void init() throws FileNotFoundException {
		InputStream inputStream = System.in; 	 OutputStream outputStream = System.out;
		try {  if (!console && System.getProperty("user.name").equals("sachan")) {
			outputStream = new FileOutputStream("/home/sachan/Desktop/output.txt");
			inputStream = new FileInputStream("/home/sachan/Desktop/input.txt");   	}
		}	catch (Exception ignored) {	}
		out = new PrintWriter(outputStream); 	 in = new FastInput(inputStream);
	}
	static class FastInput { InputStream obj;
	public FastInput(InputStream obj) {	this.obj = obj;	}
	byte inbuffer[] = new byte[1024];  int lenbuffer = 0, ptrbuffer = 0;
	int readByte() { if (lenbuffer == -1) throw new InputMismatchException();
	if (ptrbuffer >= lenbuffer) { ptrbuffer = 0;
	try { lenbuffer = obj.read(inbuffer);  }
	catch (IOException e) { throw new InputMismatchException(); } }
	if (lenbuffer <= 0) return -1;return inbuffer[ptrbuffer++]; }

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

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

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

	boolean isSpaceChar(int c) { return (!(c >= 33 && c <= 126)); }
	int skip() { int b;while ((b = readByte()) != -1 && isSpaceChar(b)) ;return b; }
	float nf() {return Float.parseFloat(ns());}
	double nd() {return Double.parseDouble(ns());}
	char nc() {return (char) skip();}
	}
}


import java.io.*;
import java.util.*;
public class eduprac implements Runnable
{
	private boolean console=false;

	public void solve()
	{
		int i; char p[]=in.ns().toCharArray(); String h=in.ns();
		Arrays.sort(p); String st=String.valueOf(p);
		int n=h.length(); int pf=p.length;
		for(i=0;i<n;i++)
		{
			char s[]=h.substring(i,Math.min(i+pf, n)).toCharArray();
			Arrays.sort(s); String sq=String.valueOf(s);
			if(sq.equals(st))
			{
				out.println("YES"); return;
			}
		}
		out.println("NO");
	}
	@Override
	public void run() {
		try {  init();  }
		catch (FileNotFoundException e) {  e.printStackTrace();   }

		int t= in.ni();

		while (t-->0) {
			solve();
			out.flush(); }
	}
	private FastInput in;    private PrintWriter out;
	public static void main(String[] args) throws Exception {	 new eduprac().run();	 }

	private void init() throws FileNotFoundException {
		InputStream inputStream = System.in; 	 OutputStream outputStream = System.out;
		try {  if (!console && System.getProperty("user.name").equals("sachan")) {
			outputStream = new FileOutputStream("/home/sachan/Desktop/output.txt");
			inputStream = new FileInputStream("/home/sachan/Desktop/input.txt");   	}
		}	catch (Exception ignored) {	}
		out = new PrintWriter(outputStream); 	 in = new FastInput(inputStream);
	}
	static class FastInput { InputStream obj;
	public FastInput(InputStream obj) {	this.obj = obj;	}
	byte inbuffer[] = new byte[1024];  int lenbuffer = 0, ptrbuffer = 0;
	int readByte() { if (lenbuffer == -1) throw new InputMismatchException();
	if (ptrbuffer >= lenbuffer) { ptrbuffer = 0;
	try { lenbuffer = obj.read(inbuffer);  }
	catch (IOException e) { throw new InputMismatchException(); } }
	if (lenbuffer <= 0) return -1;return inbuffer[ptrbuffer++]; }

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

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

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

	boolean isSpaceChar(int c) { return (!(c >= 33 && c <= 126)); }
	int skip() { int b;while ((b = readByte()) != -1 && isSpaceChar(b)) ;return b; }
	float nf() {return Float.parseFloat(ns());}
	double nd() {return Double.parseDouble(ns());}
	char nc() {return (char) skip();}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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 IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader sc = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, sc, out);
        out.close();
    }

    static class Task {
    	public long find(long x) {
    		long l=0;
    		long r=5000000;
    		long ans=-1;
    		while(l<=r) {
    			long mid=(l+r)>>1;
    			if(mid*(mid+1)/2<=x) {
    				ans=mid;
    				l=mid+1;
    			}
    			else
    				r=mid-1;
    		}
    		return ans;
    	}

        public void solve(int testNumber, InputReader sc, PrintWriter out) throws IOException {
        	int T=sc.nextInt();

        	while(T-->0) {
        		long a=sc.nextInt();
        		long b=sc.nextInt();
        		long n=Math.abs(a-b);
        		if(n==0) {
        			System.out.println(0);
        			continue;
        		}
        		long k=find(n);
        		long tk=k*(k+1)/2;
        		long tk1=(k+1)*(k+2)/2;
        		if(n==tk) {
        			System.out.println(k);
        			continue;
        		}
        		if(k%2==1) {
        			if((n-tk)%2==1)
        				System.out.println(k+2);
        			else
        				System.out.println(k+1);
        		}
        		else {
        			if((n-tk)%2==1)
        				System.out.println(k+1);
        			else
        				System.out.println(k+3);
        		}
        	}
        }

    }

    static class InputReader{
        StreamTokenizer tokenizer;
        public InputReader(InputStream stream){
            tokenizer=new StreamTokenizer(new BufferedReader(new InputStreamReader(stream)));
            tokenizer.ordinaryChars(33,126);
            tokenizer.wordChars(33,126);
        }
        public String next() throws IOException {
            tokenizer.nextToken();
            return tokenizer.sval;
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public boolean hasNext() throws IOException {
            int res=tokenizer.nextToken();
            tokenizer.pushBack();
            return res!=tokenizer.TT_EOF;
        }

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

        public BigInteger nextBigInteger() throws IOException {
        	return new BigInteger(next());
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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 IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader sc = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, sc, out);
        out.close();
    }

    static class Task {
    	public long find(long x) {
    		long l=0;
    		long r=5000000;
    		long ans=-1;
    		while(l<=r) {
    			long mid=(l+r)>>1;
    			if(mid*(mid+1)/2<=x) {
    				ans=mid;
    				l=mid+1;
    			}
    			else
    				r=mid-1;
    		}
    		return ans;
    	}

    	public boolean check(long x,long n) {
    		long s=x*(x+1)/2;
    		long l=0;
    		long r=x/2;

    		while(l<=r) {
    			long mid=(l+r)>>1;
    			if(s-mid*2==n)
    				return true;
    			if(s-mid*2>n)
    				l=mid+1;
    			else
    				r=mid-1;
    		}
    		return false;
    	}

        public void solve(int testNumber, InputReader sc, PrintWriter out) throws IOException {
        	int T=sc.nextInt();

        	while(T-->0) {
        		long a=sc.nextInt();
        		long b=sc.nextInt();
        		long n=Math.abs(a-b);
        		if(n==0) {
        			System.out.println(0);
        			continue;
        		}
        		long k=find(n);
        		while(!check(k,n))
        			k++;
        		out.println(k);
        	}
        }

    }

    static class InputReader{
        StreamTokenizer tokenizer;
        public InputReader(InputStream stream){
            tokenizer=new StreamTokenizer(new BufferedReader(new InputStreamReader(stream)));
            tokenizer.ordinaryChars(33,126);
            tokenizer.wordChars(33,126);
        }
        public String next() throws IOException {
            tokenizer.nextToken();
            return tokenizer.sval;
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public boolean hasNext() throws IOException {
            int res=tokenizer.nextToken();
            tokenizer.pushBack();
            return res!=tokenizer.TT_EOF;
        }

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

        public BigInteger nextBigInteger() throws IOException {
        	return new BigInteger(next());
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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 IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader sc = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, sc, out);
        out.close();
    }

    static class Task {
    	public int find(int x) {
    		int l=0;
    		int r=40000;
    		int ans=-1;
    		while(l<=r) {
    			int mid=(l+r)>>1;
    			if(mid*(mid+1)/2>=x) {
    				ans=mid;
    				r=mid-1;
    			}
    			else
    				l=mid+1;
    		}
    		return ans;
    	}

    	public boolean check(int ans,int n) {
    		int s=ans*(ans+1)/2;
    		for(int i=0;i<=ans;i++) {
    			if(s-i*2==n)
    				return true;
    			if(s-i<n)
    				return false;
    		}
    		return false;
    	}

        public void solve(int testNumber, InputReader sc, PrintWriter out) throws IOException {
        	int T=sc.nextInt();

        	while(T-->0) {
        		int a=sc.nextInt();
        		int b=sc.nextInt();
        		int n=Math.abs(a-b);
        		int ans=find(n);
        		while(!check(ans,n))
        			ans++;
        		out.println(ans);
        	}
        }

    }

    static class InputReader{
        StreamTokenizer tokenizer;
        public InputReader(InputStream stream){
            tokenizer=new StreamTokenizer(new BufferedReader(new InputStreamReader(stream)));
            tokenizer.ordinaryChars(33,126);
            tokenizer.wordChars(33,126);
        }
        public String next() throws IOException {
            tokenizer.nextToken();
            return tokenizer.sval;
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public boolean hasNext() throws IOException {
            int res=tokenizer.nextToken();
            tokenizer.pushBack();
            return res!=tokenizer.TT_EOF;
        }

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

        public BigInteger nextBigInteger() throws IOException {
        	return new BigInteger(next());
        }
    }
}


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

public class Main
{
	static final int mod = (int)1e9+7;
	public static void main(String[] args) throws Exception
	{
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int test = in.nextInt();
		while(test-- > 0)
		{
			int a = in.nextInt();
			int b = in.nextInt();
			int d = Math.abs(a - b);
			long s = 0;
			int ans = 0;
			for(int i = 1; s < d; i++)
			{
				s += i;
				ans++;
			}
			if(s % 2 != d % 2)
			{
				ans++;
			}
			out.println(ans);
		}
		out.flush();
	}
}

class FastReader
{
	BufferedReader br;
	StringTokenizer st;

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

	public String next() throws IOException
	{
	    if(st == null || !st.hasMoreElements())
	    {
	        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();
	}
}


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

public class Main
{
	static final int mod = (int)1e9+7;
	public static void main(String[] args) throws Exception
	{
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int test = in.nextInt();
		while(test-- > 0)
		{
			int a = in.nextInt();
			int b = in.nextInt();
			int d = Math.abs(a - b);
			long s = 0;
			int ans = 0, i;
			for(i = 1; s < d; i++)
			{
				s += i;
				ans++;
			}
			while(s % 2 != d % 2)
			{
				ans++;
				s += i;
				i++;
			}
			out.println(ans);
		}
		out.flush();
	}
}

class FastReader
{
	BufferedReader br;
	StringTokenizer st;

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

	public String next() throws IOException
	{
	    if(st == null || !st.hasMoreElements())
	    {
	        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();
	}
}


import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.InputMismatchException;

/**
 * @author Mubtasim Shahriar
 */

public class AandB {

	public static void main(String[] args) {

		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader sc = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solver solver = new Solver();
		int t = sc.nextInt();
//		int t = 1;
		while(t--!=0) {
			solver.solve(sc, out);
		}
		out.close();

	}

	static class Solver {
		public void solve(InputReader sc, PrintWriter out) {
			long a = sc.nextLong();
			long b = sc.nextLong();
//			if(a==b) {
//				out.println(0);
//				return;
//			}
			if(a>b) {
				long tmp = a;
				a = b;
				b= tmp;
			}
			double dif = b-a;
			dif++;
			double n = ((Math.sqrt(8*dif+1))-1)/2.0;
//			out.println(n);
//			out.println(dif);
			if(n%1>0) {
				long tmp = (long)(n-n%1);
//				out.println(tmp);
				long n2 = ((tmp+1)*tmp)/2;
//				out.println(n2);
				long ans = tmp+((long)dif-n2-1)*2;
				out.println(ans);
			} else {
				long tmp = (long)(n);
				long ans = (tmp-1)+(tmp-1)*2;
				out.println(ans);
			}
		}

		private int get(int now, int sec) {
			int cnt = 0;
			int inc = 1;
			while(now!=sec) {
				if(sec-now>=inc) now += inc;
				else sec += inc;
				cnt++;
				inc++;
			}
			return cnt;
		}
	}

	static class InputReader {
		private boolean finished = false;

		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private 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 int peek() {
			if (numChars == -1) {
				return -1;
			}
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					return -1;
				}
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int 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 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 String nextString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				if (Character.isValidCodePoint(c)) {
					res.appendCodePoint(c);
				}
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

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

		private String readLine0() {
			StringBuilder buf = new StringBuilder();
			int c = read();
			while (c != '\n' && c != -1) {
				if (c != '\r') {
					buf.appendCodePoint(c);
				}
				c = read();
			}
			return buf.toString();
		}

		public String readLine() {
			String s = readLine0();
			while (s.trim().length() == 0) {
				s = readLine0();
			}
			return s;
		}

		public String readLine(boolean ignoreEmptyLines) {
			if (ignoreEmptyLines) {
				return readLine();
			} else {
				return readLine0();
			}
		}

		public BigInteger readBigInteger() {
			try {
				return new BigInteger(nextString());
			} catch (NumberFormatException e) {
				throw new InputMismatchException();
			}
		}

		public char nextCharacter() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			return (char) c;
		}

		public double nextDouble() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.') {
				if (c == 'e' || c == 'E') {
					return res * Math.pow(10, nextInt());
				}
				if (c < '0' || c > '9') {
					throw new InputMismatchException();
				}
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.') {
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) {
					if (c == 'e' || c == 'E') {
						return res * Math.pow(10, nextInt());
					}
					if (c < '0' || c > '9') {
						throw new InputMismatchException();
					}
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public boolean isExhausted() {
			int value;
			while (isSpaceChar(value = peek()) && value != -1) {
				read();
			}
			return value == -1;
		}

		public String next() {
			return nextString();
		}

		public SpaceCharFilter getFilter() {
			return filter;
		}

		public void setFilter(SpaceCharFilter filter) {
			this.filter = filter;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
		public int[] nextIntArray(int n){
			int[] array=new int[n];
			for(int i=0;i<n;++i)array[i]=nextInt();
			return array;
		}
		public int[] nextSortedIntArray(int n){
			int array[]=nextIntArray(n);
			Arrays.sort(array);
			return array;
		}
		public int[] nextSumIntArray(int n){
			int[] array=new int[n];
			array[0]=nextInt();
			for(int i=1;i<n;++i)array[i]=array[i-1]+nextInt();
			return array;
		}
		public long[] nextLongArray(int n){
			long[] array=new long[n];
			for(int i=0;i<n;++i)array[i]=nextLong();
			return array;
		}
		public long[] nextSumLongArray(int n){
			long[] array=new long[n];
			array[0]=nextInt();
			for(int i=1;i<n;++i)array[i]=array[i-1]+nextInt();
			return array;
		}
		public long[] nextSortedLongArray(int n){
			long array[]=nextLongArray(n);
			Arrays.sort(array);
			return array;
		}
	}

}


import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;

/**
 * @author Mubtasim Shahriar
 */

public class AandB {

	public static void main(String[] args) {

		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader sc = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solver solver = new Solver();
		int t = sc.nextInt();
//		int t = 1;
		while(t--!=0) {
			solver.solve(sc, out);
		}
		out.close();

	}

	static class Solver {
		public void solve(InputReader sc, PrintWriter out) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			long[] sum = new long[1000001];
			if(a>b) {
				long tmp = a;
				a = b;
				b= tmp;
			}
			for(int i = 1; i < sum.length; i++) {
				sum[i] = i+ sum[i-1];
			}
			for(int i = 0; i < sum.length; i++) {
				if(sum[i]+a==b) {
					out.println(i);
					break;
				} else if(sum[i]+a>b) {
					if((sum[i]+a-b)%2==0) {
						out.println(i);
//						out.println(sum[i]);
						break;
					}
				}
			}
		}

		private int get(int now, int sec) {
			int cnt = 0;
			int inc = 1;
			while(now!=sec) {
				if(sec-now>=inc) now += inc;
				else sec += inc;
				cnt++;
				inc++;
			}
			return cnt;
		}
	}

	static class InputReader {
		private boolean finished = false;

		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private 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 int peek() {
			if (numChars == -1) {
				return -1;
			}
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					return -1;
				}
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int 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 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 String nextString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				if (Character.isValidCodePoint(c)) {
					res.appendCodePoint(c);
				}
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

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

		private String readLine0() {
			StringBuilder buf = new StringBuilder();
			int c = read();
			while (c != '\n' && c != -1) {
				if (c != '\r') {
					buf.appendCodePoint(c);
				}
				c = read();
			}
			return buf.toString();
		}

		public String readLine() {
			String s = readLine0();
			while (s.trim().length() == 0) {
				s = readLine0();
			}
			return s;
		}

		public String readLine(boolean ignoreEmptyLines) {
			if (ignoreEmptyLines) {
				return readLine();
			} else {
				return readLine0();
			}
		}

		public BigInteger readBigInteger() {
			try {
				return new BigInteger(nextString());
			} catch (NumberFormatException e) {
				throw new InputMismatchException();
			}
		}

		public char nextCharacter() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			return (char) c;
		}

		public double nextDouble() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.') {
				if (c == 'e' || c == 'E') {
					return res * Math.pow(10, nextInt());
				}
				if (c < '0' || c > '9') {
					throw new InputMismatchException();
				}
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.') {
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) {
					if (c == 'e' || c == 'E') {
						return res * Math.pow(10, nextInt());
					}
					if (c < '0' || c > '9') {
						throw new InputMismatchException();
					}
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public boolean isExhausted() {
			int value;
			while (isSpaceChar(value = peek()) && value != -1) {
				read();
			}
			return value == -1;
		}

		public String next() {
			return nextString();
		}

		public SpaceCharFilter getFilter() {
			return filter;
		}

		public void setFilter(SpaceCharFilter filter) {
			this.filter = filter;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
		public int[] nextIntArray(int n){
			int[] array=new int[n];
			for(int i=0;i<n;++i)array[i]=nextInt();
			return array;
		}
		public int[] nextSortedIntArray(int n){
			int array[]=nextIntArray(n);
			Arrays.sort(array);
			return array;
		}
		public int[] nextSumIntArray(int n){
			int[] array=new int[n];
			array[0]=nextInt();
			for(int i=1;i<n;++i)array[i]=array[i-1]+nextInt();
			return array;
		}
		public long[] nextLongArray(int n){
			long[] array=new long[n];
			for(int i=0;i<n;++i)array[i]=nextLong();
			return array;
		}
		public long[] nextSumLongArray(int n){
			long[] array=new long[n];
			array[0]=nextInt();
			for(int i=1;i<n;++i)array[i]=array[i-1]+nextInt();
			return array;
		}
		public long[] nextSortedLongArray(int n){
			long array[]=nextLongArray(n);
			Arrays.sort(array);
			return array;
		}
	}

}


import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;

/**
 * @author Mubtasim Shahriar
 */

public class AandB {

	public static void main(String[] args) {

		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader sc = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solver solver = new Solver();
		int t = sc.nextInt();
//		int t = 1;
		while(t--!=0) {
			solver.solve(sc, out);
		}
		out.close();

	}

	static class Solver {
		public void solve(InputReader sc, PrintWriter out) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			long[] sum = new long[1000001];
			if(a>b) {
				long tmp = a;
				a = b;
				b= tmp;
			}
			for(int i = 1; i < sum.length; i++) {
				sum[i] = i+ sum[i-1];
			}
			for(int i = 0; i < sum.length; i++) {
				if(sum[i]+a==b) {
					out.println(i);
					break;
				} else if(sum[i]+a>b) {
					if(sum[i]+a-b%2!=0) {
						out.println(i+1);
					} else {
						out.println(i);
					}
					break;
				}
			}
		}

		private int get(int now, int sec) {
			int cnt = 0;
			int inc = 1;
			while(now!=sec) {
				if(sec-now>=inc) now += inc;
				else sec += inc;
				cnt++;
				inc++;
			}
			return cnt;
		}
	}

	static class InputReader {
		private boolean finished = false;

		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private 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 int peek() {
			if (numChars == -1) {
				return -1;
			}
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					return -1;
				}
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int 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 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 String nextString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				if (Character.isValidCodePoint(c)) {
					res.appendCodePoint(c);
				}
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

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

		private String readLine0() {
			StringBuilder buf = new StringBuilder();
			int c = read();
			while (c != '\n' && c != -1) {
				if (c != '\r') {
					buf.appendCodePoint(c);
				}
				c = read();
			}
			return buf.toString();
		}

		public String readLine() {
			String s = readLine0();
			while (s.trim().length() == 0) {
				s = readLine0();
			}
			return s;
		}

		public String readLine(boolean ignoreEmptyLines) {
			if (ignoreEmptyLines) {
				return readLine();
			} else {
				return readLine0();
			}
		}

		public BigInteger readBigInteger() {
			try {
				return new BigInteger(nextString());
			} catch (NumberFormatException e) {
				throw new InputMismatchException();
			}
		}

		public char nextCharacter() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			return (char) c;
		}

		public double nextDouble() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.') {
				if (c == 'e' || c == 'E') {
					return res * Math.pow(10, nextInt());
				}
				if (c < '0' || c > '9') {
					throw new InputMismatchException();
				}
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.') {
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) {
					if (c == 'e' || c == 'E') {
						return res * Math.pow(10, nextInt());
					}
					if (c < '0' || c > '9') {
						throw new InputMismatchException();
					}
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public boolean isExhausted() {
			int value;
			while (isSpaceChar(value = peek()) && value != -1) {
				read();
			}
			return value == -1;
		}

		public String next() {
			return nextString();
		}

		public SpaceCharFilter getFilter() {
			return filter;
		}

		public void setFilter(SpaceCharFilter filter) {
			this.filter = filter;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
		public int[] nextIntArray(int n){
			int[] array=new int[n];
			for(int i=0;i<n;++i)array[i]=nextInt();
			return array;
		}
		public int[] nextSortedIntArray(int n){
			int array[]=nextIntArray(n);
			Arrays.sort(array);
			return array;
		}
		public int[] nextSumIntArray(int n){
			int[] array=new int[n];
			array[0]=nextInt();
			for(int i=1;i<n;++i)array[i]=array[i-1]+nextInt();
			return array;
		}
		public long[] nextLongArray(int n){
			long[] array=new long[n];
			for(int i=0;i<n;++i)array[i]=nextLong();
			return array;
		}
		public long[] nextSumLongArray(int n){
			long[] array=new long[n];
			array[0]=nextInt();
			for(int i=1;i<n;++i)array[i]=array[i-1]+nextInt();
			return array;
		}
		public long[] nextSortedLongArray(int n){
			long array[]=nextLongArray(n);
			Arrays.sort(array);
			return array;
		}
	}

}


/*
	Created by stdnoob(Shivansh Patel) on 19/12/2019 11:13 PM
	Codeforces Round 78(Div. 2) : : Problem B : : A and B
*/
import java.util.*;
import java.io.*;
public class codeforces
{
	public static void main(String args[]) throws IOException
	{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int q = Integer.parseInt(br.readLine());
		while(q-- != 0)
		{
			String s[]=(br.readLine()).split(" ");
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			if(a>b)
			{
				int temp=a;
				a=b;
				b=temp;
			}
			int count=0;
			int adder=1;
			while(a<b)
			{
				count++;
				a+=adder;
				adder++;
			}
			if(a>b)
			{
				count++;
			}
			System.out.println(count);
		}
	}
}


/*
	Created by stdnoob(Shivansh Patel) on 19/12/2019 11:13 PM
	Codeforces Round 78(Div. 2) : : Problem B : : A and B
*/
import java.util.*;
import java.io.*;
public class codeforces
{
	public static void main(String args[]) throws IOException
	{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int q = Integer.parseInt(br.readLine());
		while(q-- != 0)
		{
			String s[]=(br.readLine()).split(" ");
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			if(a>b)
			{
				int temp=a;
				a=b;
				b=temp;
			}
			int count=0;
			int adder=1;
			while(a<b)
			{
				count++;
				a+=adder;
				adder++;
			}
			System.out.println(count);
		}
	}
}


/*
	Created by stdnoob(Shivansh Patel) on 19/12/2019 11:13 PM
	Codeforces Round 78(Div. 2) : : Problem B : : A and B
*/
import java.util.*;
import java.io.*;
public class codeforces
{
	public static void main(String args[]) throws IOException
	{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int q = Integer.parseInt(br.readLine());
		while(q-- != 0)
		{
			String s[]=(br.readLine()).split(" ");
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			if(a>b)
			{
				int temp=a;
				a=b;
				b=temp;
			}
		int k = 0;
			while (a < b || (a - b) % 2 == 1)
				a += ++k;
			System.out.println(k);
		}
	}
}


// No sorceries shall previal. //
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.*;
import java.util.Arrays;

public class _InVoker_ {

    public static void sort(int arr[], int start, int end) {
		if(start>=end)
			return;
		int mid=(start+end)/2;
		sort(arr,start,mid);
		sort(arr,mid+1,end);
		merge(arr,start,mid,end);
	}
	private static void merge(int arr[], int start, int mid, int end) {
		int i, j=mid+1,c=0;
		int temp[]= new int[end-start+1];
		for(i=start;i<=mid && j<=end;c++) {
			if(arr[i]<=arr[j]) {
				temp[c]=arr[i];
				i++;
			}
			else {
				temp[c]=arr[j];
				j++;
			}
		}
		while(i<=mid) {
			temp[c]=arr[i];
			i++;c++;
		}
		while(j<=end) {
			temp[c]=arr[j];
			j++;c++;
		}
		c=0;
		for(i=start;i<=end;i++,c++)
			arr[i]=temp[c];
	}
	static class ListNode {
		ListNode(){
			data=0;
			next=null;
		}
		ListNode(int data){
			this.data=data;
		}
		ListNode(char a){
			this.a=a;
		}
		private char a;
		private int data;
		private ListNode next;

		public char getCharData() {
			return a;
		}
		public void setCharData(char x) {
			a=x;
		}
		public int getData() {
			return data;
		}
		public void setData(int data) {
			this.data = data;
		}
		public ListNode getNext() {
			return next;
		}
		public void setNext(ListNode next) {
			this.next = next;
		}
	}
	static long gcd(long a, long b)
    {
      if (b == 0)
        return a;
      return gcd(b, a % b);
    }
	public static void main(String args[]) {

    	Scanner inp=new Scanner(System.in);
    	PrintWriter out= new PrintWriter(System.out);

    	long ans[]=new long[100005];
    	long sum=1;
    	for(int i=1;i<100005;i++) {
    		ans[i]=ans[i-1]+i;
    	}
    	int t=inp.nextInt();
    	while(t-->0) {
    		long x=inp.nextLong();
    		long y=inp.nextLong();
    		x=Math.max(x, y)-Math.min(x, y);
    		int z=(int)Math.sqrt((long)x);
    		//out.println(z);
    		for(int i=z;i<z+5;i++) {
    			if(ans[i]==x) {
    				out.println(i);
    				break;
    			}
    			else if(ans[i]>x && x%2==ans[i]%2) {
    				out.println(i);
    				break;
    			}
    		}
    	}
    	inp.close();
    	out.close();
    }
}


// No sorceries shall previal. //
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.*;
import java.util.Arrays;

public class _InVoker_ {

    public static void sort(int arr[], int start, int end) {
		if(start>=end)
			return;
		int mid=(start+end)/2;
		sort(arr,start,mid);
		sort(arr,mid+1,end);
		merge(arr,start,mid,end);
	}
	private static void merge(int arr[], int start, int mid, int end) {
		int i, j=mid+1,c=0;
		int temp[]= new int[end-start+1];
		for(i=start;i<=mid && j<=end;c++) {
			if(arr[i]<=arr[j]) {
				temp[c]=arr[i];
				i++;
			}
			else {
				temp[c]=arr[j];
				j++;
			}
		}
		while(i<=mid) {
			temp[c]=arr[i];
			i++;c++;
		}
		while(j<=end) {
			temp[c]=arr[j];
			j++;c++;
		}
		c=0;
		for(i=start;i<=end;i++,c++)
			arr[i]=temp[c];
	}
	static class ListNode {
		ListNode(){
			data=0;
			next=null;
		}
		ListNode(int data){
			this.data=data;
		}
		ListNode(char a){
			this.a=a;
		}
		private char a;
		private int data;
		private ListNode next;

		public char getCharData() {
			return a;
		}
		public void setCharData(char x) {
			a=x;
		}
		public int getData() {
			return data;
		}
		public void setData(int data) {
			this.data = data;
		}
		public ListNode getNext() {
			return next;
		}
		public void setNext(ListNode next) {
			this.next = next;
		}
	}
	static long gcd(long a, long b)
    {
      if (b == 0)
        return a;
      return gcd(b, a % b);
    }
	public static void main(String args[]) {

    	Scanner inp=new Scanner(System.in);
    	PrintWriter out= new PrintWriter(System.out);

    	long ans[]=new long[50000];
    	long sum=1;
    	for(int i=1;i<50000;i++) {
    		ans[i]=ans[i-1]+i;
    	}
    	int t=inp.nextInt();
    	while(t-->0) {
    		long x=inp.nextLong();
    		long y=inp.nextLong();
    		x=Math.max(x, y)-Math.min(x, y);
    		int z=(int)Math.sqrt((long)x);
    		//out.println(z);
    		for(int i=z;i<50000;i++) {
    			if(ans[i]==x) {
    				out.println(i);
    				break;
    			}
    			else if(ans[i]>x && x%2==ans[i]%2) {
    				out.println(i);
    				break;
    			}
    		}
    	}
    	inp.close();
    	out.close();
    }
}


//REMEMBER TO COMMENT PACKAGE AND SAVEEEE YOU MONKEY lol
//package cf;
import java.util.*;
import java.io.*;
public class AandB{
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	static StringTokenizer st;
	public static void main(String[]args)throws IOException {
		//REMEMBER TO COMMENT PACKAGE AND SAVEEEE YOU MONKEY lol
		int n = readInt();
		for(int i = 0; i<n; i++) {
			int a = readInt();
			int b = readInt();
			int c = Math.abs(a-b);
			long ll = 0;
			for(int j = 0; j<=100000; j++) {
				ll+=j;
				if(ll>=c) {
					if((ll-c)%2==0) {
						System.out.println(j);
						break;
					}
				}
			}
		}
	}
	static String next () throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}
	static long readLong () throws IOException {
		return Long.parseLong(next());
	}
	static int readInt () throws IOException {
		return Integer.parseInt(next());
	}
	static double readDouble () throws IOException {
		return Double.parseDouble(next());
	}
	static char readCharacter () throws IOException {
		return next().charAt(0);
	}
	static String readLine () throws IOException {
		return br.readLine().trim();
	}
}


//REMEMBER TO COMMENT PACKAGE AND SAVEEEE YOU MONKEY lol
//package cf;
import java.util.*;
import java.io.*;
public class AandB{
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	static StringTokenizer st;
	public static void main(String[]args)throws IOException {
		//REMEMBER TO COMMENT PACKAGE AND SAVEEEE YOU MONKEY lol
		int n = readInt();
		for(int i = 0; i<n; i++) {
			int a = readInt();
			int b = readInt();
			int c = Math.min(a, b);
			int d = Math.max(a, b);
			int total = 0;
			int rem = (d-c)%6;
			total+=(d-c)/6;
			if(rem == 1) {
				total+=1;
			}
			if(rem==2) {
				total+=3;
			}
			if(rem==3) {
				total+=2;
			}
			if(rem==4) {
				total+=3;
			}
			if(rem==5) {
				total+=4;
			}
			System.out.println(total);
		}
	}
	static String next () throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}
	static long readLong () throws IOException {
		return Long.parseLong(next());
	}
	static int readInt () throws IOException {
		return Integer.parseInt(next());
	}
	static double readDouble () throws IOException {
		return Double.parseDouble(next());
	}
	static char readCharacter () throws IOException {
		return next().charAt(0);
	}
	static String readLine () throws IOException {
		return br.readLine().trim();
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
//BigInteger A;
//A= BigInteger.valueOf(54);
//ArrayList<Integer> a=new ArrayList<>();
//TreeSet<Integer> ts=new TreeSet<>();
//HashMap<Integer,Integer> hm=new HashMap<>();
//PriorityQueue<Integer> pq=new PriorityQueue<>();
public final class CF
{
    public static void main(String[]args)throws IOException
    {
        FastReader ob=new FastReader();
        int t=ob.nextInt();
        while(t-->0)
        {
            long a=ob.nextLong();
            long b=ob.nextLong();
            long k=Math.abs(b-a);
            k=8*k+1;
            double x=Math.sqrt(k);
            if(x==Math.ceil(x))
            {
                long ans=((long)x-1)/2;
                System.out.println(ans);
                continue;
            }
            int p=1;
            while(true)
            {
                long p1=(p*(p+1))/2;
                if((a+b+p1)%2==0)
                {
                    long x1=(a+b+p1)/2;
                    if(x1>Math.max(a,b))
                    {
                        System.out.println(p);
                        break;
                    }
                }
                ++p;
            }
        }
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;
    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e)  {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    public String nextLine()
    {
        String s="";
        try {
        s=br.readLine();
        } catch (IOException e)  {
                e.printStackTrace();
            }
        return s;
    }
    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.lang.*;
import java.io.*;
import java.math.*;
//BigInteger A;
//A= BigInteger.valueOf(54);
//ArrayList<Integer> a=new ArrayList<>();
//TreeSet<Integer> ts=new TreeSet<>();
//HashMap<Integer,Integer> hm=new HashMap<>();
//PriorityQueue<Integer> pq=new PriorityQueue<>();
public final class CF
{
    public static void main(String[]args)throws IOException
    {
        FastReader ob=new FastReader();
        int t=ob.nextInt();
        while(t-->0)
        {
            long a=ob.nextLong();
            long b=ob.nextLong();
            long k=Math.abs(b-a);
            k=8*k+1;
            double x=Math.sqrt(k);
            if(x==Math.ceil(x))
            {
                long ans=((long)x-1)/2;
                System.out.println(ans);
                continue;
            }
            long p=1;
            while(true)
            {
                long p1=(p*(p+1))/2;
                if((a+b+p1)%2==0)
                {
                    long x1=(a+b+p1)/2;
                    if(x1>Math.max(a,b))
                    {
                        System.out.println(p);
                        break;
                    }
                }
                ++p;
            }
        }
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;
    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e)  {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    public String nextLine()
    {
        String s="";
        try {
        s=br.readLine();
        } catch (IOException e)  {
                e.printStackTrace();
            }
        return s;
    }
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.min;
import static java.lang.System.exit;

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

public class Main {

	static void solve() throws Exception {
		int n=nextInt();
		while(n-->0) {
			int a=nextInt();
			int b=nextInt();
			int z=0;
			int x=1;
			int c=1;
			while(a!=b) {
				if(b-a>=c) {
					a+=c;
					c++;
					z++;
				}else if(c<=a-b) {
					b+=c;
					c++;
					z++;
			   }else if(b-a<c) {
				   b+=c;
					c++;
					z++;
					a+=c;
					c++;
					z++;
			   }else if(a-b<c) {
				   a+=c;
					c++;
					z++;
					b+=c;
					c++;
					z++;
			   }
			}
		   out.println(z);
		}

	}

	static int nextInt() throws IOException {
		return parseInt(nextString());
	}

	static long nextLong() throws IOException {
		return parseLong(nextString());
	}

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

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

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


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

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

public class Main {

	static void solve() throws Exception {
		int t=nextInt();
		 while(t-->0) {
		long a=nextLong(),b=nextLong();
		 a=abs(a-b);
//		System.out.println(a);
		if(a==0) {
			out.println(0);
			continue;
	}
		for (int i = 0;;i++) {
			long sum=i*(i+1)/2;
			if(a%2!=sum%2) {
				continue;
			}
			if(a>sum) {
				continue;
			}
			out.println(i);
			 break;
		}
		 }
	}

	static int nextInt() throws IOException {
		return parseInt(nextString());
	}

	static long nextLong() throws IOException {
		return parseLong(nextString());
	}

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

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

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			solve();

			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package solution;

/**
 *
 * @author USER
 */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Solution{
    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        public InputReader(InputStream st) {
            this.stream = st;
        }
        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
            c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public int[] nia(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public String rs() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                    c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
    public static class Key {

        private final int x;
        private final int y;

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

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Key)) return false;
            Key key = (Key) o;
            return x == key.x && y == key.y;
        }

        @Override
        public int hashCode() {
            int result = x;
            result = 31 * result + y;
            return result;
        }

    }

    static PrintWriter w = new PrintWriter(System.out);
    static long mod=998244353L,mod1=1000000007;
    static int co[][];
    static void dsort(){
        Arrays.parallelSort(co,(o1,o2)->o1[0]!=o2[0]?o1[0]-o2[0]:o1[1]-o2[1]);
    }
     static long  power(long x, long y) {
        long temp=0;
        if( y == 0)
            return 1;
        temp = power(x, y/2);
        if (y%2 == 0)
            return (temp*temp)%mod1;
        else
            return (((x*temp)%mod1)*temp)%mod1;
    }
    static long modInverse(long a, long m){
        long num=m;
        long x=1;
        long power=a%mod1;
        while(num>0){
              if(num%2==1){
                  x=(x*power)%mod1;
            }
            num>>=1;
            power=(power*power)%mod1;
        }
        return x;
    }
    static long ncrWithoutMod(int n,int r){
        if(n<r)return 0L;
        long ans=fact[n]/(fact[r]*fact[n-r]);
        return ans;
    }
    static long fact[]=new long[1000005];
    public static void findFact(){
        fact[0]=1;
        for(int i=1;i<=1000000;i++){
            fact[i]=(i*fact[i-1])%mod1;
        }
    }

    public static void main(String [] args){
        InputReader sdf=new InputReader(System.in);
        //Scanner sc=new Scanner(System.in);
       // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                  int t=sdf.ni();
            next: while(t-->0){
               long r=sdf.nl();
               long b=sdf.nl();
               long diff=Math.abs(r-b);
               long sum=0;
               int i=0;
               while(true){
                   if(sum>=diff&&sum%2==diff%2){
                       System.out.println(i);
                       continue next;
                   }
                   else{
                       i++;
                       sum=sum+i;
                   }
               }
            }
        w.close();

    }

//
//

      ///RKC

//    static long ncr(long n, long r)
//    {    if(r==0)return 1;
//            else {
//                long ans=n%M;
//                ans*=ncr(n-1,r-1)%M;
//                ans%=M;
//                ans*=inverse(r)%M;
//                ans%=M;return ans;
//
//    }
//
//    }
//    static long fast_exp(long x,long n){
//        long ans=1;
//        while(n>0){
//            if((n&1)!=0){
//                ans*=x;
//                ans%=M;
//            }
//            n=n>>1;
//            x=(x*x)%M;
//        }
//        return ans;
//    }
//static long inverse(long x){return fast_exp(x,M-2);}
//
//
//        ///RKC
//
//
//
//
//        static long bigpowmod(long a,long n,long m){
//            a=a%m;
//            long res=1;
//            while(n>0){
//                if((n&1)!=0){
//                    res=(res*a);
//                    res=res%m;
//                }
//                a=(a*a)%m;
//                n=n>>1;
//
//            }
//
//            return res;
//        }
//
//        static long printNcR(long n, long r) {
//
//        // p holds the value of n*(n-1)*(n-2)...,
//        // k holds the value of r*(r-1)...
//        long p = 1, k = 1;
//
//        // C(n, r) == C(n, n-r),
//        // choosing the smaller value
//        if (n - r < r) {
//            r = n - r;
//        }
//
//        if (r != 0) {
//            while (r > 0) {
//                p *= n;
//                k *= r;
//
//                // gcd of p, k
//                long m = __gcd(p, k);
//
//                // dividing by gcd, to simplify product
//                // division by their gcd saves from the overflow
//                p /= m;
//                k /= m;
//
//                n--;
//                r--;
//            }
//
//            // k should be simplified to 1
//            // as C(n, r) is a natural number
//            // (denominator should be 1 ) .
//        } else {
//            p = 1;
//        }
//
//        // if our approach is correct p = ans and k =1
//       return p;
//    }
//
//    static long __gcd(long n1, long n2) {
//        long gcd = 1;
//
//        for (int i = 1; i <= n1 && i <= n2; ++i) {
//            // Checks if i is factor of both integers
//            if (n1 % i == 0 && n2 % i == 0) {
//                gcd = i;
//            }
//        }
//        return gcd;
//    }
//        static long power(int x,int y)
//        {
//            long temp;
//            if( y == 0)
//                return 1;
//                temp = power(x, y/2);
//                if (y%2 == 0)
//                     return temp*temp;
//                    else
//                    return x*temp*temp;
//}

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

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            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;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            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;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

//

class MySort {
    public void selectionSort(int[]a,int left,int right){
        //left index from 0 and right= last index
        for(int i=left;i<=right;i++){
            int min_index=i;
            for(int j=i+1;j<=right;j++){
                if(a[min_index]>a[j])min_index=j;
            }
            int temp=a[min_index];
            a[min_index]=a[i];
            a[i]=temp;
        }
    }

    public void bubbleSort(int a[],int  left,int right){
        //left index from 0 and right= last index

        for(int i=left;i<=right;i++){
            for(int j=left;j<right;j++){
                if(a[j+1]<a[j]){
                    int temp=a[j+1];
                    a[j+1]=a[j];
                    a[j]=temp;
                }
            }
        }
    }

    public void insertionSort(int a[],int left,int right){
        //left index from 0 and right= last index
        for(int i=left+1;i<=right;i++){
            int temp=a[i];
            int j=i-1;
            for(;j>=0&&temp<a[j];j--){
                a[j+1]=a[j];
            }
            a[j+1]=temp;
        }
    }

    public void quickSort(int a[],int left,int right){
        //left index from 0 and right= last index
        if(left<right){
            int pi_index=partition(a,left,right);

            quickSort(a,pi_index+1,right);//for left side of pivot
            quickSort(a,left,pi_index-1);//for right side of pivot

        }

    }
    private int partition(int a[],int left,int right){
            //last element is used as pivot
            int pivot=a[right];
            int i=left-1;
            for(int j=left;j<right;j++){
                if(pivot>a[j]){
                    i++;
                    int temp=a[i];
                    a[i]=a[j];
                    a[j]=temp;
                }
            }
            int temp=a[i+1];
            a[i+1]=a[right];
            a[right]=temp;
            return i+1;
    }

    public void mergeSort(int []a,int left,int right){
        if(left<right){
            int m=(left+right)/2;
            mergeSort(a, left, m);
            mergeSort(a, m+1, right);
            merging(a,left,m,right);

        }

    }
    private void merging(int[]a,int left,int m,int right){
        int n1=m-left+1;
        int n2=right-(m+1)+1;
        int []L=new int[n1];
        int []R=new int[n2];

        for(int i=0;i<n1;i++){L[i]=a[left+i];}
        for(int i=0;i<n2;i++){R[i]=a[m+1+i];}

        int i=0;int j=0;
        int k=left;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else {
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    }

}
}