using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;

class Program {
    static void Main(string[] args) {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        var solver = new Solver(sw);
        // var t = new Thread(solver.solve, 1 << 26); // 64 MB
        // t.Start();
        // t.Join();
        solver.solve();
        sw.Flush();
    }
}

class Solver {
    StreamWriter sw;
    Scan sc;
    void Prt(string a) => sw.WriteLine(a);
    void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
    void Prt(params object[] a) => Prt(string.Join(" ", a));
    public Solver(StreamWriter sw) {
        this.sw = sw;
        this.sc = new Scan();
    }

    public void solve() {
        int n, t;
        sc.Multi(out n, out t);
        var s = new int[n];
        var g = new int[n];
        for (int i = 0; i < n; i++)
        {
            sc.Multi(out s[i], out g[i]);
            --g[i];
        }
        memo = new long[n + 1][][][];
        for (int i = 0; i < n + 1; i++)
        {
            memo[i] = new long[n + 1][][];
            for (int j = 0; j < n + 1; j++)
            {
                memo[i][j] = new long[n + 1][];
                for (int k = 0; k < n + 1; k++)
                {
                    memo[i][j][k] = new long[4];
                    for (int l = 0; l < 4; l++)
                    {
                        memo[i][j][k][l] = -1;
                    }
                }
            }
        }
        long ans = 0;
        for (int i = 0; i < (1 << n); i++)
        {
            int sum = 0;
            var cnt = new int[3];
            for (int j = 0; j < n; j++)
            {
                if (((i >> j) & 1) == 1) {
                    sum += s[j];
                    ++cnt[g[j]];
                }
            }
            if (sum != t) continue;
            ans += dfs(cnt[0], cnt[1], cnt[2], 3);
        }
        Prt(ans % M);
    }
    long[][][][] memo;
    long dfs(int a, int b, int c, int prev) {
        if (a < 0 || b < 0 || c < 0) return 0;
        if (a == 0 && b == 0 && c == 0) return 1;
        if (memo[a][b][c][prev] != -1) return memo[a][b][c][prev];
        long sum = 0;
        if (prev != 0) sum += dfs(a - 1, b, c, 0) * a;
        if (prev != 1) sum += dfs(a, b - 1, c, 1) * b;
        if (prev != 2) sum += dfs(a, b, c - 1, 2) * c;
        return memo[a][b][c][prev] = sum % M;
    }
}

class pair<T, U> : IComparable<pair<T, U>> {
    public T v1;
    public U v2;
    public pair() : this(default(T), default(U)) {}
    public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; }
    public int CompareTo(pair<T, U> a) {
        int c = Comparer<T>.Default.Compare(v1, a.v1);
        return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
    }
    public override string ToString() => v1 + " " + v2;
    public void Deconstruct(out T a, out U b) { a = v1; b = v2; }
}
static class util {
    public static readonly int M = 1000000007;
    // public static readonly int M = 998244353;
    public static readonly long LM = 1L << 60;
    public static readonly double eps = 1e-11;
    public static void DBG(string a) => Console.Error.WriteLine(a);
    public static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
    public static void DBG(params object[] a) => DBG(string.Join(" ", a));
    public static void Assert(bool cond) { if (!cond) throw new Exception(); }
    public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1, v2);
    public static int CompareList<T>(IList<T> a, IList<T> b) where T : IComparable<T> {
        for (int i = 0; i < a.Count && i < b.Count; i++)
            if (a[i].CompareTo(b[i]) != 0) return a[i].CompareTo(b[i]);
        return a.Count.CompareTo(b.Count);
    }
    public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
    static readonly int[] dd = { 0, 1, 0, -1 };
    // static readonly string dstring = "RDLU";
    public static P[] adjacents(int i, int j)
        => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1])).ToArray();
    public static P[] adjacents(int i, int j, int h, int w)
        => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1]))
                                         .Where(p => inside(p.v1, p.v2, h, w)).ToArray();
    public static P[] adjacents(this P p) => adjacents(p.v1, p.v2);
    public static P[] adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2, h, w);
    public static Dictionary<T, int> compress<T>(this IEnumerable<T> a)
        => a.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);
    public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a) => compress(a.Aggregate(Enumerable.Union));
    public static T[] inv<T>(this Dictionary<T, int> dic) {
        var res = new T[dic.Count];
        foreach (var item in dic) res[item.Value] = item.Key;
        return res;
    }
    public static void swap<T>(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }
    public static void swap<T>(this IList<T> a, int i, int j) where T : struct { var t = a[i]; a[i] = a[j]; a[j] = t; }
    public static T[] copy<T>(this IList<T> a) {
        var ret = new T[a.Count];
        for (int i = 0; i < a.Count; i++) ret[i] = a[i];
        return ret;
    }
}

class Scan {
    StreamReader sr;
    public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }
    public Scan(string path) { sr = new StreamReader(path); }
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public string Str => sr.ReadLine().Trim();
    public pair<T, U> Pair<T, U>() {
        T a; U b;
        Multi(out a, out b);
        return new pair<T, U>(a, b);
    }
    public P P => Pair<int, int>();
    public int[] IntArr => StrArr.Select(int.Parse).ToArray();
    public long[] LongArr => StrArr.Select(long.Parse).ToArray();
    public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
    public string[] StrArr => Str.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);
    bool eq<T, U>() => typeof(T).Equals(typeof(U));
    T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
    T cv<T>(string s) => eq<T, int>()    ? ct<T, int>(int.Parse(s))
                       : eq<T, long>()   ? ct<T, long>(long.Parse(s))
                       : eq<T, double>() ? ct<T, double>(double.Parse(s))
                       : eq<T, char>()   ? ct<T, char>(s[0])
                                         : ct<T, string>(s);
    public void Multi<T>(out T a) => a = cv<T>(Str);
    public void Multi<T, U>(out T a, out U b)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); }
    public void Multi<T, U, V>(out T a, out U b, out V c)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); }
    public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); }
    public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using SB = System.Text.StringBuilder;
//using System.Threading.Tasks;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
using System.Numerics;
using static System.Math;
using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    readonly int dom = 998244353;
    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void solve()
    {
        int N = cin.nextint;
        int T = cin.nextint;

        var A = new int[N];
        var G = new int[N];
        var co = new BinomialCoefficient(20);

        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextint;
            G[i] = cin.nextint - 1;
        }

        ModInt ans = 0;
        for (int S = 0; S < 1 << N; S++)
        {
            int time = 0;
            var type = new int[3];
            for (int i = 0; i < N; i++)
            {
                if ((S >> i & 1) == 1)
                {
                    time += A[i];
                    type[G[i]]++;
                }
            }
            if (time != T)
            {
                continue;
            }
            int X = type[0];
            int Y = type[1];
            int Z = type[2];

            var dp = new long[type[0] + 1, type[1] + 1, type[2] + 1, 4];

            for (int i = 0; i <= X; i++)
            {
                for (int j = 0; j <= Y; j++)
                {
                    for (int k = 0; k <= Z; k++)
                    {
                        for (int l = 0; l < 4; l++)
                        {
                            dp[i, j, k, l] = -1;
                        }
                    }
                }
            }
            ModInt ret = calc(X, Y, Z, 3, dp);
            if (X > 1) ret = ret * co.fact[X];
            if (Y > 1) ret = ret * co.fact[Y];
            if (Z > 1) ret = ret * co.fact[Z];
            ans += ret;

        }
        WriteLine(ans);
    }

    long calc(int x, int y, int z, int before, long[,,,] dp)
    {
        //WriteLine(x + " " + y + " " + z);
        if (dp[x, y, z, before] >= 0)
        {
            return dp[x, y, z, before];
        }
        if (x == 0 && y == 0 && z == 0)
        {
            return 1;
        }

        long ret = 0;
        if (x > 0 && before != 0)
        {
            ret += calc(x - 1, y, z, 0, dp);
        }
        if (y > 0 && before != 1)
        {
            ret += calc(x, y - 1, z, 1, dp);
        }
        if (z > 0 && before != 2)
        {
            ret += calc(x, y, z - 1, 2, dp);
        }
        ret %= mod;
        return dp[x, y, z, before] = ret;
    }

}

/// <summary>
/// [0,<see cref="Mod"/>) までの値を取るような数
/// </summary>
/// <OriginalAuthor>camypaper</OriginalAuthor>
struct ModInt
{
    /// <summary>
    /// 剰余を取る値．
    /// </summary>
    public const long Mod = (int)1e9 + 7;

    /// <summary>
    /// 実際の数値．
    /// </summary>
    public long num;
    /// <summary>
    /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
    /// </summary>
    /// <param name="n">インスタンスが持つ値</param>
    /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
    public ModInt(long n) { num = n; }
    /// <summary>
    /// このインスタンスの数値を文字列に変換します．
    /// </summary>
    /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
    public override string ToString() { return num.ToString(); }
    public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
    public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
    public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
    public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

    /// <summary>
    /// 与えられた 2 つの数値からべき剰余を計算します．
    /// </summary>
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

    /// <summary>
    /// 与えられた 2 つの数値からべき剰余を計算します．
    /// </summary>
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(long v, long k)
    {
        long ret = 1;
        for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
            if ((k & 1) == 1) ret = ret * v % Mod;
        return new ModInt(ret);
    }
    /// <summary>
    /// 与えられた数の逆元を計算します．
    /// </summary>
    /// <param name="v">逆元を取る対象となる数</param>
    /// <returns>逆元となるような値</returns>
    /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
    public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
}

class BinomialCoefficient
{
    public ModInt[] fact, ifact;
    /// <summary>
    /// <paramref name="n"/>は <paramref name="Mod"/>未満でお願いします。
    /// </summary>
    /// <param name="n"></param>
    public BinomialCoefficient(ModInt _n)
    {
        int n = (int)_n.num;
        fact = new ModInt[n + 1];
        ifact = new ModInt[n + 1];
        fact[0] = 1;
        for (int i = 1; i <= n; i++)
            fact[i] = fact[i - 1] * i;
        ifact[n] = ModInt.Inverse(fact[n]);
        for (int i = n - 1; i >= 0; i--)
            ifact[i] = ifact[i + 1] * (i + 1);
        ifact[0] = ifact[1];
    }
    public ModInt this[int n, int r]
    {
        get
        {
            if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
            return fact[n] * ifact[n - r] * ifact[r];
        }
    }
    public ModInt RepeatedCombination(int n, int k)
    {
        if (k == 0) return 1;
        return this[n + k - 1, k];
    }
}

static class Ex
{
    public static void join<T>(this IEnumerable<T> values, string sep = " ") => WriteLine(string.Join(sep, values));
    public static string concat<T>(this IEnumerable<T> values) => string.Concat(values);
    public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }

    public static int lower_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) < 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    public static int upper_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) <= 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
}

class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
    public T f; public U s;
    public Pair(T f, U s) { this.f = f; this.s = s; }
    public int CompareTo(Pair<T, U> a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);
    public override string ToString() => $"{f} {s}";
}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan => ReadLine().Split();
    public int[] scanint => Array.ConvertAll(scan, int.Parse);
    public long[] scanlong => Array.ConvertAll(scan, long.Parse);
    public double[] scandouble => Array.ConvertAll(scan, double.Parse);
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint => int.Parse(next);
    public long nextlong => long.Parse(next);
    public double nextdouble => double.Parse(next);
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using SB = System.Text.StringBuilder;
//using System.Threading.Tasks;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
using System.Numerics;
using static System.Math;
using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    readonly int dom = 998244353;
    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void solve()
    {
        int N = cin.nextint;
        int T = cin.nextint;

        var A = new int[N];
        var G = new int[N];

        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextint;
            G[i] = cin.nextint - 1;
        }

        ModInt ans = 0;
        for (int S = 0; S < 1 << N; S++)
        {
            int time = 0;
            var type = new int[3];
            for (int i = 0; i < N; i++)
            {
                if ((S >> i & 1) == 1)
                {
                    time += A[i];
                    type[G[i]]++;
                }
            }
            if (time != T)
            {
                continue;
            }
            int X = type[0];
            int Y = type[1];
            int Z = type[2];

            var dp = new long[type[0] + 1, type[1] + 1, type[2] + 1, 4];

            for (int i = 0; i <= X; i++)
            {
                for (int j = 0; j <= Y; j++)
                {
                    for (int k = 0; k <= Z; k++)
                    {
                        for (int l = 0; l < 4; l++)
                        {
                            dp[i, j, k, l] = -1;
                        }
                    }
                }
            }
            var ret = calc(X, Y, Z, 3, dp);
            if (X > 1) ret = ret * X;
            if (Y > 1) ret = ret * Y;
            if (Z > 1) ret = ret * Z;
            ans += ret % mod;

        }
        WriteLine(ans);
    }

    long calc(int x, int y, int z, int before, long[,,,] dp)
    {
        //WriteLine(x + " " + y + " " + z);
        if (dp[x, y, z, before] >= 0)
        {
            return dp[x, y, z, before];
        }
        if (x == 0 && y == 0 && z == 0)
        {
            return 1;
        }

        long ret = 0;
        if (x > 0 && before != 0)
        {
            ret += calc(x - 1, y, z, 0, dp);
        }
        if (y > 0 && before != 1)
        {
            ret += calc(x, y - 1, z, 1, dp);
        }
        if (z > 0 && before != 2)
        {
            ret += calc(x, y, z - 1, 2, dp);
        }
        ret %= mod;
        return dp[x, y, z, before] = ret;
    }

}

/// <summary>
/// [0,<see cref="Mod"/>) までの値を取るような数
/// </summary>
/// <OriginalAuthor>camypaper</OriginalAuthor>
struct ModInt
{
    /// <summary>
    /// 剰余を取る値．
    /// </summary>
    public const long Mod = (int)1e9 + 7;

    /// <summary>
    /// 実際の数値．
    /// </summary>
    public long num;
    /// <summary>
    /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
    /// </summary>
    /// <param name="n">インスタンスが持つ値</param>
    /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
    public ModInt(long n) { num = n; }
    /// <summary>
    /// このインスタンスの数値を文字列に変換します．
    /// </summary>
    /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
    public override string ToString() { return num.ToString(); }
    public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
    public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
    public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
    public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

    /// <summary>
    /// 与えられた 2 つの数値からべき剰余を計算します．
    /// </summary>
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

    /// <summary>
    /// 与えられた 2 つの数値からべき剰余を計算します．
    /// </summary>
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(long v, long k)
    {
        long ret = 1;
        for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
            if ((k & 1) == 1) ret = ret * v % Mod;
        return new ModInt(ret);
    }
    /// <summary>
    /// 与えられた数の逆元を計算します．
    /// </summary>
    /// <param name="v">逆元を取る対象となる数</param>
    /// <returns>逆元となるような値</returns>
    /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
    public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
}

class BinomialCoefficient
{
    public ModInt[] fact, ifact;
    /// <summary>
    /// <paramref name="n"/>は <paramref name="Mod"/>未満でお願いします。
    /// </summary>
    /// <param name="n"></param>
    public BinomialCoefficient(ModInt _n)
    {
        int n = (int)_n.num;
        fact = new ModInt[n + 1];
        ifact = new ModInt[n + 1];
        fact[0] = 1;
        for (int i = 1; i <= n; i++)
            fact[i] = fact[i - 1] * i;
        ifact[n] = ModInt.Inverse(fact[n]);
        for (int i = n - 1; i >= 0; i--)
            ifact[i] = ifact[i + 1] * (i + 1);
        ifact[0] = ifact[1];
    }
    public ModInt this[int n, int r]
    {
        get
        {
            if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
            return fact[n] * ifact[n - r] * ifact[r];
        }
    }
    public ModInt RepeatedCombination(int n, int k)
    {
        if (k == 0) return 1;
        return this[n + k - 1, k];
    }
}

static class Ex
{
    public static void join<T>(this IEnumerable<T> values, string sep = " ") => WriteLine(string.Join(sep, values));
    public static string concat<T>(this IEnumerable<T> values) => string.Concat(values);
    public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }

    public static int lower_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) < 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    public static int upper_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) <= 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
}

class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
    public T f; public U s;
    public Pair(T f, U s) { this.f = f; this.s = s; }
    public int CompareTo(Pair<T, U> a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);
    public override string ToString() => $"{f} {s}";
}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan => ReadLine().Split();
    public int[] scanint => Array.ConvertAll(scan, int.Parse);
    public long[] scanlong => Array.ConvertAll(scan, long.Parse);
    public double[] scandouble => Array.ConvertAll(scan, double.Parse);
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint => int.Parse(next);
    public long nextlong => long.Parse(next);
    public double nextdouble => double.Parse(next);
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class Program
{
	int[][] c;
	int n, m;
	int mod = 1000000007;
	int add(int x, int y)
	{
		x += y;
		return x < mod ? x : x - mod;
	}
	int mul(int x, int y)
	{
		return Convert.ToInt32(Convert.ToInt64(x) * y % mod);
	}
	int[][] newMatrix(int m)
	{
		int[][] ret = new int[m][];
		for (int i = 0; i < m; i++)
			ret[i] = new int[m];
		return ret;
	}
	void calcSum(ref int[][] sum, int[][] a)
	{
		for (int i = 1; i <= m; i++)
			for (int j = 1; j <= m; j++)
				sum[i][j] = add(sum[i - 1][j], a[i][j]);
		for (int i = 1; i <= m; i++)
			for (int j = 1; j <= m; j++)
				sum[i][j] = add(sum[i][j - 1], sum[i][j]);
	}
	int regionSum(int[][] sum, int lx, int rx, int ly, int ry)
	{
		--lx; --ly;
		return add(add(sum[lx][ly],sum[rx][ry]), mod - add(sum[lx][ry],sum[rx][ly]));
	}
	void run()
	{
		String[] str = Console.ReadLine().Split(' ');
		n = Convert.ToInt32(str[0]);
		m = Convert.ToInt32(str[1]);
		int[][][] dp11 = new int[n + 1][][],
			dp10 = new int[n + 1][][],
			dp01 = new int[n + 1][][],
			dp00 = new int[n + 1][][];
		dp11[1] = newMatrix(m + 1);
		dp10[1] = newMatrix(m + 1);
		dp01[1] = newMatrix(m + 1);
		dp00[1] = newMatrix(m + 1);
		for (int i = 1; i <= m; i++)
			for (int j = i; j <= m; j++)
				dp11[1][i][j] = 1;
		int[][] sum = newMatrix(m + 1);
		for (int i = 2; i <= n; i++)
		{
			dp11[i] = newMatrix(m + 1);
			dp10[i] = newMatrix(m + 1);
			dp01[i] = newMatrix(m + 1);
			dp00[i] = newMatrix(m + 1);
			calcSum(ref sum, dp11[i - 1]);
			for (int j = 1; j <= m; j++)
				for (int k = j; k <= m; k++)
				{
					dp11[i][j][k] = add(dp11[i][j][k], regionSum(sum, j, k, j, k));
					dp10[i][j][k] = add(dp10[i][j][k], regionSum(sum, j, k, k + 1, m));
					dp01[i][j][k] = add(dp01[i][j][k], regionSum(sum, 1, j - 1, j, k));
					dp00[i][j][k] = add(dp00[i][j][k], regionSum(sum, 1, j - 1, k + 1, m));
				}
			calcSum(ref sum, dp10[i - 1]);
			for (int j = 1; j <= m; j++)
				for (int k = j; k <= m; k++)
				{
					dp10[i][j][k] = add(dp10[i][j][k], regionSum(sum, j, k, k, m));
					dp00[i][j][k] = add(dp00[i][j][k], regionSum(sum, 1, j - 1, k, m));
				}
			calcSum(ref sum, dp01[i - 1]);
			for (int j = 1; j <= m; j++)
				for (int k = j; k <= m; k++)
				{
					dp01[i][j][k] = add(dp01[i][j][k], regionSum(sum, 1, j, j, k));
					dp00[i][j][k] = add(dp00[i][j][k], regionSum(sum, 1, j, k + 1, m));
				}
			calcSum(ref sum, dp00[i - 1]);
			for (int j = 1; j <= m; j++)
				for (int k = j; k <= m; k++)
				{
					dp00[i][j][k] = add(dp00[i][j][k], regionSum(sum, 1, j, k, m));
				}
		}
		int res = 0;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
				for (int k = 1; k <= m; k++)
					res = add(res, mul(n - i + 1, add(add(dp00[i][j][k],dp01[i][j][k]), add(dp10[i][j][k],dp11[i][j][k]))));
		Console.WriteLine(res);
	}
	static void Main(String[] args)
	{
		new Program().run();
	}
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using CodeforcesRound608Div2.Questions;

namespace CodeforcesRound608Div2.Questions
{
    public class QuestionE : AtCoderQuestionBase
    {
        public override void Solve(IOManager io)
        {
            var n = io.ReadLong();
            var k = io.ReadLong();

            var result = 0L;

            // 偶数
            result.ChangeMax(BoundaryBinarySearch(i =>
            {
                var x = i * 2;
                var left = x;
                var right = x + 1;

                long paths = right <= n ? 2 : 1;

                while (true)
                {
                    left <<= 1;
                    right <<= 1;
                    right++;

                    if (left > n)
                    {
                        break;
                    }
                    else if (right > n)
                    {
                        paths += n - left + 1;
                        break;
                    }
                    else
                    {
                        paths += right - left + 1;
                    }
                }

                return paths >= k;
            }, 0, n / 2 + 1) * 2);

            // 奇数
            result.ChangeMax(BoundaryBinarySearch(i =>
            {
                var x = i * 2 + 1;
                var left = x;
                var right = x;

                long paths = 1;

                while (true)
                {
                    left <<= 1;
                    right <<= 1;
                    right++;

                    if (left > n)
                    {
                        break;
                    }
                    else if (right > n)
                    {
                        paths += n - left + 1;
                        break;
                    }
                    else
                    {
                        paths += right - left + 1;
                    }
                }

                return paths >= k;
            }, 0, (n - 1) / 2 + 1) * 2 + 1);

            io.WriteLine(result);
        }

        public static long BoundaryBinarySearch(Predicate<long> predicate, long ok, long ng)
        {
            // めぐる式二分探索
            while (Math.Abs(ok - ng) > 1)
            {
                long mid = (ok + ng) / 2;
                if (predicate(mid))
                {
                    ok = mid;
                }
                else
                {
                    ng = mid;
                }
            }
            return ok;
        }
    }
}

namespace CodeforcesRound608Div2
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionE();
            using var io = new IOManager(Console.OpenStandardInput(), Console.OpenStandardOutput());
            question.Solve(io);
        }
    }
}

#region Base Class

namespace CodeforcesRound608Div2.Questions
{
    public interface IAtCoderQuestion
    {
        string Solve(string input);
        void Solve(IOManager io);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public string Solve(string input)
        {
            var inputStream = new MemoryStream(Encoding.UTF8.GetBytes(input));
            var outputStream = new MemoryStream();
            using var manager = new IOManager(inputStream, outputStream);

            Solve(manager);
            manager.Flush();

            outputStream.Seek(0, SeekOrigin.Begin);
            var reader = new StreamReader(outputStream);
            return reader.ReadToEnd();
        }

        public abstract void Solve(IOManager io);
    }
}

#endregion

#region Utils

namespace CodeforcesRound608Div2
{
    public class IOManager : IDisposable
    {
        private readonly BinaryReader _reader;
        private readonly StreamWriter _writer;
        private bool _disposedValue;
        private byte[] _buffer = new byte[1024];
        private int _length;
        private int _cursor;
        private bool _eof;

        const char ValidFirstChar = '!';
        const char ValidLastChar = '~';

        public IOManager(Stream input, Stream output)
        {
            _reader = new BinaryReader(input);
            _writer = new StreamWriter(output) { AutoFlush = false };
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private char ReadAscii()
        {
            if (_cursor == _length)
            {
                _cursor = 0;
                _length = _reader.Read(_buffer);

                if (_length == 0)
                {
                    if (!_eof)
                    {
                        _eof = true;
                        return char.MinValue;
                    }
                    else
                    {
                        ThrowEndOfStreamException();
                    }
                }
            }

            return (char)_buffer[_cursor++];
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public char ReadChar()
        {
            char c;
            while (!IsValidChar(c = ReadAscii())) { }
            return c;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public string ReadString()
        {
            var builder = new StringBuilder();
            char c;
            while (!IsValidChar(c = ReadAscii())) { }

            do
            {
                builder.Append(c);
            } while (IsValidChar(c = ReadAscii()));

            return builder.ToString();
        }

        public int ReadInt() => (int)ReadLong();

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long ReadLong()
        {
            long result = 0;
            bool isPositive = true;
            char c;

            while (!IsNumericChar(c = ReadAscii())) { }

            if (c == '-')
            {
                isPositive = false;
                c = ReadAscii();
            }

            do
            {
                result *= 10;
                result += c - '0';
            } while (IsNumericChar(c = ReadAscii()));

            return isPositive ? result : -result;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private Span<char> ReadChunk(Span<char> span)
        {
            var i = 0;
            char c;
            while (!IsValidChar(c = ReadAscii())) { }

            do
            {
                span[i++] = c;
            } while (IsValidChar(c = ReadAscii()));

            return span.Slice(0, i);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public double ReadDouble() => double.Parse(ReadChunk(stackalloc char[32]));

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public decimal ReadDecimal() => decimal.Parse(ReadChunk(stackalloc char[32]));

        public int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }

        public long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }

        public double[] ReadDoubleArray(int n)
        {
            var a = new double[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = ReadDouble();
            }
            return a;
        }

        public decimal[] ReadDecimalArray(int n)
        {
            var a = new decimal[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = ReadDecimal();
            }
            return a;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void WriteLine<T>(T value) => _writer.WriteLine(value.ToString());

        public void WriteLine<T>(IEnumerable<T> values, char separator)
        {
            var e = values.GetEnumerator();
            if (e.MoveNext())
            {
                _writer.Write(e.Current.ToString());

                while (e.MoveNext())
                {
                    _writer.Write(separator);
                    _writer.Write(e.Current.ToString());
                }
            }

            _writer.WriteLine();
        }

        public void WriteLine<T>(Span<T> values, char separator) => WriteLine((ReadOnlySpan<T>)values, separator);

        public void WriteLine<T>(ReadOnlySpan<T> values, char separator)
        {
            for (int i = 0; i < values.Length - 1; i++)
            {
                _writer.Write(values[i]);
                _writer.Write(separator);
            }

            if (values.Length > 0)
            {
                _writer.Write(values[^1]);
            }

            _writer.WriteLine();
        }

        public void Flush() => _writer.Flush();

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static bool IsValidChar(char c) => ValidFirstChar <= c && c <= ValidLastChar;

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static bool IsNumericChar(char c) => ('0' <= c && c <= '9') || c == '-';

        private void ThrowEndOfStreamException() => throw new EndOfStreamException();

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    _reader.Dispose();
                    _writer.Flush();
                    _writer.Dispose();
                }

                _disposedValue = true;
            }
        }

        public void Dispose()
        {
            Dispose(disposing: true);
            GC.SuppressFinalize(this);
        }
    }

    public static class UtilExtensions
    {
        public static bool ChangeMax<T>(ref this T a, T b) where T : struct, IComparable<T>
        {
            if (a.CompareTo(b) < 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        public static bool ChangeMin<T>(ref this T a, T b) where T : struct, IComparable<T>
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        public static void Sort<T>(this T[] array) where T : IComparable<T> => Array.Sort(array);
        public static void Sort<T>(this T[] array, Comparison<T> comparison) => Array.Sort(array, comparison);
    }
}

#endregion


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using CodeforcesRound608Div2.Questions;

namespace CodeforcesRound608Div2.Questions
{
    public class QuestionE : AtCoderQuestionBase
    {
        public override void Solve(IOManager io)
        {
            var n = io.ReadLong();
            var k = io.ReadLong();

            var result = 0L;

            // 偶数
            result.ChangeMax(BoundaryBinarySearch(i =>
            {
                var x = i * 2;
                var left = x;
                var right = x + 1;

                long paths = right <= n ? 2 : 1;

                while (true)
                {
                    left <<= 1;
                    right <<= 1;
                    right++;

                    if (left > n)
                    {
                        break;
                    }
                    else if (right > n)
                    {
                        paths += n - left + 1;
                        break;
                    }
                    else
                    {
                        paths += right - left + 1;
                    }
                }

                return paths >= k;
            }, 0, n / 2) * 2);

            // 奇数
            result.ChangeMax(BoundaryBinarySearch(i =>
            {
                var x = i * 2 + 1;
                var left = x;
                var right = x;

                long paths = 1;

                while (true)
                {
                    left <<= 1;
                    right <<= 1;
                    right++;

                    if (left > n)
                    {
                        break;
                    }
                    else if (right > n)
                    {
                        paths += n - left + 1;
                        break;
                    }
                    else
                    {
                        paths += right - left + 1;
                    }
                }

                return paths >= k;
            }, 0, (n - 1) / 2) * 2 + 1);

            io.WriteLine(result);
        }

        public static long BoundaryBinarySearch(Predicate<long> predicate, long ok, long ng)
        {
            // めぐる式二分探索
            while (Math.Abs(ok - ng) > 1)
            {
                long mid = (ok + ng) / 2;
                if (predicate(mid))
                {
                    ok = mid;
                }
                else
                {
                    ng = mid;
                }
            }
            return ok;
        }
    }
}

namespace CodeforcesRound608Div2
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionE();
            using var io = new IOManager(Console.OpenStandardInput(), Console.OpenStandardOutput());
            question.Solve(io);
        }
    }
}

#region Base Class

namespace CodeforcesRound608Div2.Questions
{
    public interface IAtCoderQuestion
    {
        string Solve(string input);
        void Solve(IOManager io);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public string Solve(string input)
        {
            var inputStream = new MemoryStream(Encoding.UTF8.GetBytes(input));
            var outputStream = new MemoryStream();
            using var manager = new IOManager(inputStream, outputStream);

            Solve(manager);
            manager.Flush();

            outputStream.Seek(0, SeekOrigin.Begin);
            var reader = new StreamReader(outputStream);
            return reader.ReadToEnd();
        }

        public abstract void Solve(IOManager io);
    }
}

#endregion

#region Utils

namespace CodeforcesRound608Div2
{
    public class IOManager : IDisposable
    {
        private readonly BinaryReader _reader;
        private readonly StreamWriter _writer;
        private bool _disposedValue;
        private byte[] _buffer = new byte[1024];
        private int _length;
        private int _cursor;
        private bool _eof;

        const char ValidFirstChar = '!';
        const char ValidLastChar = '~';

        public IOManager(Stream input, Stream output)
        {
            _reader = new BinaryReader(input);
            _writer = new StreamWriter(output) { AutoFlush = false };
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private char ReadAscii()
        {
            if (_cursor == _length)
            {
                _cursor = 0;
                _length = _reader.Read(_buffer);

                if (_length == 0)
                {
                    if (!_eof)
                    {
                        _eof = true;
                        return char.MinValue;
                    }
                    else
                    {
                        ThrowEndOfStreamException();
                    }
                }
            }

            return (char)_buffer[_cursor++];
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public char ReadChar()
        {
            char c;
            while (!IsValidChar(c = ReadAscii())) { }
            return c;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public string ReadString()
        {
            var builder = new StringBuilder();
            char c;
            while (!IsValidChar(c = ReadAscii())) { }

            do
            {
                builder.Append(c);
            } while (IsValidChar(c = ReadAscii()));

            return builder.ToString();
        }

        public int ReadInt() => (int)ReadLong();

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long ReadLong()
        {
            long result = 0;
            bool isPositive = true;
            char c;

            while (!IsNumericChar(c = ReadAscii())) { }

            if (c == '-')
            {
                isPositive = false;
                c = ReadAscii();
            }

            do
            {
                result *= 10;
                result += c - '0';
            } while (IsNumericChar(c = ReadAscii()));

            return isPositive ? result : -result;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private Span<char> ReadChunk(Span<char> span)
        {
            var i = 0;
            char c;
            while (!IsValidChar(c = ReadAscii())) { }

            do
            {
                span[i++] = c;
            } while (IsValidChar(c = ReadAscii()));

            return span.Slice(0, i);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public double ReadDouble() => double.Parse(ReadChunk(stackalloc char[32]));

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public decimal ReadDecimal() => decimal.Parse(ReadChunk(stackalloc char[32]));

        public int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }

        public long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }

        public double[] ReadDoubleArray(int n)
        {
            var a = new double[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = ReadDouble();
            }
            return a;
        }

        public decimal[] ReadDecimalArray(int n)
        {
            var a = new decimal[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = ReadDecimal();
            }
            return a;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void WriteLine<T>(T value) => _writer.WriteLine(value.ToString());

        public void WriteLine<T>(IEnumerable<T> values, char separator)
        {
            var e = values.GetEnumerator();
            if (e.MoveNext())
            {
                _writer.Write(e.Current.ToString());

                while (e.MoveNext())
                {
                    _writer.Write(separator);
                    _writer.Write(e.Current.ToString());
                }
            }

            _writer.WriteLine();
        }

        public void WriteLine<T>(Span<T> values, char separator) => WriteLine((ReadOnlySpan<T>)values, separator);

        public void WriteLine<T>(ReadOnlySpan<T> values, char separator)
        {
            for (int i = 0; i < values.Length - 1; i++)
            {
                _writer.Write(values[i]);
                _writer.Write(separator);
            }

            if (values.Length > 0)
            {
                _writer.Write(values[^1]);
            }

            _writer.WriteLine();
        }

        public void Flush() => _writer.Flush();

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static bool IsValidChar(char c) => ValidFirstChar <= c && c <= ValidLastChar;

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static bool IsNumericChar(char c) => ('0' <= c && c <= '9') || c == '-';

        private void ThrowEndOfStreamException() => throw new EndOfStreamException();

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    _reader.Dispose();
                    _writer.Flush();
                    _writer.Dispose();
                }

                _disposedValue = true;
            }
        }

        public void Dispose()
        {
            Dispose(disposing: true);
            GC.SuppressFinalize(this);
        }
    }

    public static class UtilExtensions
    {
        public static bool ChangeMax<T>(ref this T a, T b) where T : struct, IComparable<T>
        {
            if (a.CompareTo(b) < 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        public static bool ChangeMin<T>(ref this T a, T b) where T : struct, IComparable<T>
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        public static void Sort<T>(this T[] array) where T : IComparable<T> => Array.Sort(array);
        public static void Sort<T>(this T[] array, Comparison<T> comparison) => Array.Sort(array, comparison);
    }
}

#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeForces
{
    class R183_Div2_D
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int x = int.Parse(s[2]);
            int y = int.Parse(s[3]);
            int a = int.Parse(s[4]);
            int b = int.Parse(s[5]);
            int g = GCD_Euclid(a, b);
            a = a / g;
            b = b / g;

            int xDif = Math.Min(n - x, x - 0);
            int yDif = Math.Min(m - y, y - 0);

            int t = Math.Min(n / a, m / b);
            a *= t;
            b *= t;

            int x1, y1, x2, y2;
            x1 = x - a + (a / 2);
            y1 = y - b + (b / 2);
            x1 = Math.Min(x1, n - a);
            y1 = Math.Min(y1, m - b);
            x1 = Math.Max(x1, 0);
            y1 = Math.Max(y1, 0);
            x2 = x1 + a;
            y2 = y1 + b;
            Console.WriteLine(x1 + " " + y1 + " " + x2 + " " + y2);
        }

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


#define Online
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);

    class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            long n, m, x, y, a, b;
            string[] input = ReadArray();
            n = long.Parse(input[0]);
            m = long.Parse(input[1]);
            x = long.Parse(input[2]);
            y = long.Parse(input[3]);
            a = long.Parse(input[4]);
            b = long.Parse(input[5]);

            long gcd = MyMath.GCD(a, b);
            a /= gcd;
            b /= gcd;

            long left = 1;
            long right = m;

            long mid;
            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (mid * a >= n || mid * b >= m)
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }
            if (!(left * a <= n && left * b <= m))
                left--;

            long w, h;
            w = left * a;
            h = left * b;
            long x1, y1, x2, y2;
            x1 = x2 = y1 = y2 = 0;

            if (x + w / 2 > n)
            {
                x1 = x - (w % 2L == 0 ? w / 2L : w / 2L + 1L) - (x + w / 2L - n);
                x2 = x1 + w;
            }
            else
            {
                if (x - (w % 2 == 0 ? w / 2 : w / 2 + 1) < 0)
                {
                    x1 = 0;
                    x2 = w;
                }
                else
                {
                    x1 = x - (w % 2L == 0 ? w / 2L : w / 2L + 1L);
                    x2 = x1 + w;
                }
            }
            if (y + h / 2 > m)
            {
                y1 = y - (h % 2L == 0 ? h / 2L : h / 2L + 1L) - (y + h / 2L - m);
                y2 = y1 + h;
            }
            else
            {
                if (y - (h % 2 == 0 ? h / 2 : h / 2 + 1) < 0)
                {
                    y1 = 0;
                    y2 = h;
                }
                else
                {
                    y1 = y - (h % 2L == 0 ? h / 2L : h / 2L + 1L);
                    y2 = y1 + h;
                }
            }

            Console.WriteLine(x1 + " " + y1 + " " + x2 + " " + y2);
#if Online
            Console.ReadLine();
#endif

#if FileIO
            sr.Close();
            sw.Close();
#endif
        }

        static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
    }

    public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long GCD(long a, long b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static int GCD(int a, int b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

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

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

    public class SegmentTree
    {
        int[] v_min;
        int[] v_max;
        int[] mas;
        public void BuildTree(int[] a)
        {
            int n = a.Length - 1;
            int z = 0;
            while (n >= 2)
            {
                z++;
                n >>= 1;
            }
            n = 1 << (z + 1);
            v_min = new int[n << 1];
            v_max = new int[n << 1];
            mas = new int[n << 1];
            for (int i = n; i < n + a.Length; i++)
                v_min[i] = a[i - n];
            for (int i = n + a.Length; i < v_min.Length; i++)
                v_min[i] = int.MaxValue;
            for (int i = n - 1; i > 0; i--)
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);

            for (int i = n; i < n + a.Length; i++)
                v_max[i] = a[i - n];
            for (int i = n + a.Length; i < v_max.Length; i++)
                v_max[i] = int.MinValue;
            for (int i = n - 1; i > 0; i--)
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);

        }
        //nil
        public int RMQ_MIN(int l, int r)
        {
            int ans = int.MaxValue;
            l += v_min.Length >> 1;
            r += v_min.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Min(ans, v_min[l]);
                if (!((r & 1) == 0))
                    ans = Math.Min(ans, v_min[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public int RMQ_MAX(int l, int r)
        {
            int ans = int.MinValue;
            l += v_max.Length >> 1;
            r += v_max.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Max(ans, v_max[l]);
                if (!((r & 1) == 0))
                    ans = Math.Max(ans, v_max[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public void Put(int l, int r, int op)
        {
            l += mas.Length >> 1;
            r += mas.Length >> 1;
            while (l <= r)
            {
                if (l % 2 != 0)
                    mas[l] = op;
                if (r % 2 == 0)
                    mas[r] = op;
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
        }

        public int Get(int x)
        {
            x += mas.Length >> 1;
            int ans = int.MinValue;
            while (x > 0)
            {
                ans = Math.Max(mas[x], ans);
                x >>= 1;
            }
            return ans;
        }

        public void Update(int i, int x)
        {
            i += v_min.Length >> 1;
            v_min[i] = x;
            v_max[i] = x;
            i >>= 1;
            while (i > 0)
            {
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);
                i >>= 1;
            }
        }
    }
    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }
    class Graph
    {
        public List<List<int>> g = new List<List<int>>();
        public List<Edge> e = new List<Edge>();
        public Stack<int> s;
        public List<bool> u;
        public List<int> d; //длина
        public List<int> p; //путь
        public Queue<int> q;
        public int n;
        public int start;
        public int finish;
        public Graph(int n)
        {
            for (int i = 0; i <= n; i++)
                g.Add(new List<int>());
            p = new List<int>();
            d = new List<int>();
            for (int i = 0; i <= n; i++)
                p.Add(-1);
            for (int i = 0; i <= n; i++)
                d.Add(-1);
            u = new List<bool>();
            for (int i = 0; i <= n; i++)
                u.Add(true);
            this.n = n;
        }

        public bool dfs1(int v)
        {
            u[v] = false;
            for (int i = 0; i < g[v].Count; i++)
            {
                if (u[g[v][i]])
                {
                    p[g[v][i]] = v;
                    if (dfs1(g[v][i])) return true;
                }
                else
                {
                    if (p[v] != g[v][i])
                    {
                        start = v;
                        finish = g[v][i];
                        return true;
                    }
                }
            }
            return false;
        }

        public void dfs2(int v)
        {
            s = new Stack<int>();
            s.Push(v);
            int cur;
            bool all;
            while (s.Count != 0)
            {
                cur = s.Peek();
                all = true;
                for (int i = 0; i < g[cur].Count; i++)
                {
                    if (d[g[cur][i]] == -1)
                    {
                        s.Push(g[cur][i]);
                        d[g[cur][i]] = d[cur] + 1;
                        all = false;
                    }
                }
                if (all)
                    s.Pop();
            }
        }

        public void DFS(int v)
        {
            s = new Stack<int>();

            s.Push(v);
            int cur;
            bool all;
            while (s.Count != 0)
            {
                cur = s.Peek();
                u[cur] = false;
                all = true;
                for (int i = 0; i < g[cur].Count; i++)
                {
                    if (u[g[cur][i]])
                    {
                        all = false;
                        p[g[cur][i]] = cur;
                        s.Push(g[cur][i]);
                    }
                    else
                    {
                        if (p[cur] != g[cur][i])
                        {
                            start = cur;
                            finish = g[cur][i];
                            return;
                        }
                    }
                }
                if (all)
                    s.Pop();
            }
        }

        public void BFS(params int[] v)
        {
            q = new Queue<int>();
            u = new List<bool>();
            d = new List<int>();
            p = new List<int>();

            for (int i = 0; i <= n; i++)
            {
                u.Add(true);
                d.Add(0);
                p.Add(0);
            }

            q.Enqueue(v[0]);
            u[v[0]] = false;
            int cur;

            while (q.Count != 0)
            {
                cur = q.Dequeue();
                for (int i = 0; i < g[cur].Count; i++)
                    if (u[g[cur][i]])
                    {
                        q.Enqueue(g[cur][i]);
                        u[g[cur][i]] = false;
                        p[g[cur][i]] = cur;
                        d[g[cur][i]] = d[cur] + 1;
                    }
            }

            int from = v[1];
            string path = from + "";
            while (p[from] != 0)
            {
                path = p[from] + " " + path;
                from = p[from];
            }
            Console.WriteLine(d[v[1]] + " : " + path);
        }

        public void FordBellman(params int[] v)
        {
            d = new List<int>();
            p = new List<int>();
            for (int i = 0; i <= n; i++)
            {
                d.Add(int.MaxValue);
                p.Add(0);
            }
            d[v[0]] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < e.Count; j++)
                {
                    if (d[e[j].a] != int.MaxValue)
                    {
                        if (d[e[j].a] + e[j].w < d[e[j].b])
                        {
                            d[e[j].b] = d[e[j].a] + e[j].w;
                            p[e[j].b] = e[j].a;
                        }
                    }
                }
            }

            int from = v[1];

            if (d[from] == int.MaxValue)
            {
                Console.WriteLine("Can't find the minimal path");
                return;
            }

            string ans = from + "";
            while (p[from] != 0)
            {
                ans = p[from] + " " + ans;
                from = p[from];
            }

            Console.WriteLine(d[v[1]] + " : " + ans);
        }
    }
    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R);
            Merge_Sort(A, q + 1, r, L, R);
            Merge(A, p, q, r, L, R);
        }

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}


using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Globalization;
using System.Collections.Generic;
using System.Threading;
using kp.Algo;

namespace CodeForces
{
	internal class Solution
	{
		const int StackSize = 20 * 1024 * 1024;

		private void Solve()
		{
			long n = NextLong(), m = NextLong(), x = NextLong(), y = NextLong(), a = NextLong(), b = NextLong();
			long g = NumTheoryUtils.Gcd( a, b );
			a /= g;
			b /= g;
			long k = Math.Min( n / a, m / b );
			long xl = k * a, yl = k * b;
			long x1 = ( xl % 2 == 0 ? x - xl / 2 : x - xl / 2 - 1 );
			long y1 = ( yl % 2 == 0 ? y - yl / 2 : y - yl / 2 - 1 );
			if ( x1 < 0 ) x1 = 0;
			if ( y1 < 0 ) y1 = 0;
			if ( x1 + xl > n ) x1 -= ( x1 + xl ) - n;
			if ( y1 + yl > m ) y1 -= ( y1 + yl ) - m;
			Out.WriteLine( string.Format( "{0} {1} {2} {3}", x1, y1, x1 + xl, y1 + yl ) );
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, StackSize );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new Solution().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}

namespace kp.Algo { }

namespace kp.Algo
{
	static class NumTheoryUtils
	{
		public static long Gcd( long a, long b )
		{
			if ( a < 0 ) a = -a;
			if ( b < 0 ) b = -b;
			return b == 0 ? a : Gcd( b, a % b );
		}
	}
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Codeforces
{
    class Program {

        #region input

        static long readLong() {
            long num;
            long.TryParse(Console.ReadLine(),out num);
            return num;
        }

        static ulong readULong() {
            ulong num;
            ulong.TryParse(Console.ReadLine(),out num);
            return num;
        }

        static int readInt() {
            int num;
            int.TryParse(Console.ReadLine(),out num);
            return num;
        }

        static bool readBool() {
            int num;
            int.TryParse(Console.ReadLine(),out num);
            return num != 0;
        }

        static long[] readLongs() {
            string[] nums = Console.ReadLine().Split(new char[] { ' ' });
            long[] parsed = new long[nums.Length];
            for(int i = 0; i < nums.Length; i++) {
                long.TryParse(nums[i],out parsed[i]);
            }
            return parsed;
        }

        static int[] readInts() {
            string[] nums = Console.ReadLine().Split(new char[] { ' ' });
            int[] parsed = new int[nums.Length];
            for(int i = 0; i < nums.Length; i++) {
                int.TryParse(nums[i],out parsed[i]);
            }
            return parsed;
        }

        static void readInts(out int a, out  int b) {
            string[] nums = Console.ReadLine().Split(new char[] { ' ' });
            int[] parsed = new int[nums.Length];
            int.TryParse(nums[0],out a);
            int.TryParse(nums[1],out b);
        }

        static BitArray readBools() {
            string[] nums = Console.ReadLine().Split(new char[] { ' ' });
            BitArray bits = new BitArray(nums.Length);
            for(int i = 0; i < nums.Length; i++) {
                if(nums[i] != "0") {
                    bits[i] = true;
                }
            }
            return bits;
        }

        static BitArray readBools(string off) {
            string[] nums = Console.ReadLine().Split(new char[] { ' ' });
            BitArray bits = new BitArray(nums.Length);
            for(int i = 0; i < nums.Length; i++) {
                if(nums[i] != off) {
                    bits[i] = true;
                }
            }
            return bits;
        }

        static void waist() {
            Console.ReadLine();
        }

        #endregion

        #region utility

        static long largeModolu(long a,long b,long m) {
            long prev = a;
            long sum = (b & 1) > 0 ? a : 1;
            int digits = (int)(Math.Ceiling(Math.Log(b,2)));
            for(int i = 1; i < digits; i++) {
                prev = (prev * prev) % (m);
                if((b & (1l << i)) > 0) {
                    sum = (sum * prev) % (m);
                }
            }
            return sum;
        }

        static long GCD(long a, long b) {
            long temp;
            if(a > b) {
                temp = b;
                b = a;
                a = temp;
            }
            while(b != 0) {
                temp = b;
                b = a % b;
                a = temp;
            }
            return a;
        }

        class SortableKVP<T> where T : IComparable {
            List<Tuple<int,T>> data { set; get; }

            public int count {
                get {
                    return data.Count;
                }
            }

            public T this[int index] {
                get {
                    return data[index].Item2;
                }
            }

            public int originalIndex(int sortedIndex) {
                return data[sortedIndex].Item1;
            }

            public void sort() {
                data.Sort((a,b) => a.Item2.CompareTo(b.Item2));
            }

            public void add(T item) {
                data.Add(new Tuple<int,T>(data.Count,item));
            }

            public void removeAt(int sortedIndex) {
                data.RemoveAt(sortedIndex);
            }

            public SortableKVP() {
                data = new List<Tuple<int,T>>();
            }

            public SortableKVP(T[] data) {
                this.data = new List<Tuple<int,T>>(data.Length);
                for(int i = 0; i < data.Length; i++) {
                    this.data.Add(new Tuple<int,T>(i,data[i]));
                }
            }
        }

        #endregion

        static void Main(string[] args) {
            long[] nmxyab = readLongs();
            long n = nmxyab[0];
            long m = nmxyab[1];
            long x = nmxyab[2];
            long y = nmxyab[3];
            long a = nmxyab[4];
            long b = nmxyab[5];
            long gcd = GCD(a,b);
            a /= gcd;
            b /= gcd;
            long multiplier = Math.Min(n / a,m / b);
            long xLength = a * multiplier;
            long yLength = b * multiplier;
            long x1 = Math.Min(n - xLength,Math.Max(0,x - (xLength + 1) / 2));
            long y1 = Math.Min(m - yLength,Math.Max(0,y - (yLength + 1) / 2));
            Console.WriteLine(x1 + " " + y1 + " " + (x1 + xLength) + " " + (y1 + yLength));
        }

        /*static void Main(string[] args) {
            BitArray primes = new BitArray(1000001,true);
            primes[0] = false;
            primes[1] = false;
            for(int i = 2; i * i <= 1000000; i++) {
                if(primes[i]) {
                    for(int j = i * 2; j <= 1000000; j += i) {
                        primes[j] = false;
                    }
                }
            }
            int t = readInt();
            for(int r = 0; r < t; r++) {
                int[] range = readInts();
                int sum = 0;
                for(int i = range[0]; i <= range[1]; i++) {
                    if(primes[i]) {
                        sum++;
                    }
                }
                Console.WriteLine(sum);
            }
            Console.Read();
        }*/

        /*static void Main(string[] args) {
            int t = readInt();
            for(int r = 0; r < t; r++) {
                waist();
                int[] nums = readInts();
                Array.Sort(nums, (a,b) => b.CompareTo(a));
                for(int i = 0; i < nums.Length; i++) {
                    if((i & 1) == 0 ) {
                        Console.Write(nums[i/2]);
                    } else {
                        Console.Write(nums[nums.Length - 1- (i-1)/2]);
                    }
                    if(i == nums.Length - 1) {
                        Console.WriteLine("");
                    } else {
                        Console.Write(" ");
                    }
                }
            }
            Console.Read();
        }*/
    }
}
//0.89493155168539774035319
//0.894931551685397740353194
//0.894931551685397735434921


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Threading;

namespace D
{
    class Program
    {
        public static int gcd(int a, int b)
        {
            if (a < b)
            {
                return gcd(b, a);
            }
            else
            {
                if (b == 0)
                {
                    return a;
                }
                else
                {
                    return gcd(b, a % b);
                }
            }
        }
        static void Main(string[] args)
        {
#if !ONLINE_JUDGE
            Console.SetIn(new System.IO.StreamReader(@"..\..\..\in"));
            Console.SetOut(new System.IO.StreamWriter(@"..\..\..\out"));
            for (int testN = 0; testN < 2; testN++)
            {
#endif
                //SetCulture();
                var n = NextInt();
                var m = NextInt();
                var x = NextInt();
                var y = NextInt();
                var a = NextInt();
                var b = NextInt();

                var g = gcd(a, b);
                a = a / g;
                b = b / g;
                var ma = n / a;
                var mb = m / b;
                var k = Math.Min(ma, mb);
                var mx = k * a;
                var my = k * b;

                var x1 = x - ((mx + 1) / 2);
                var y1 = y - ((my + 1) / 2);
                var x2 = x + (mx / 2);
                var y2 = y + (my / 2);
                if (x1 < 0)
                {
                    x2 += -x1;
                    x1 = 0;
                }
                if (x2 > n)
                {
                    x1 -= (x2 - n);
                    x2 = n;
                }
                if (y1 < 0)
                {
                    y2 += -y1;
                    y1 = 0;
                }
                if (y2 > m)
                {
                    y1 -= (y2 - m);
                    y2 = m;
                }

                Console.WriteLine("{0} {1} {2} {3}", x1, y1, x2, y2);
                //Console.WriteLine(string.Format(NumberFormatInfo.InvariantInfo, "{0:F4}", res));
#if !ONLINE_JUDGE
                Console.ReadLine();
            }
            Console.In.Close();
            Console.Out.Close();
#endif
        }

        private static char[] _defaultSplitter = new char[] { ' ', '\t' };

        private static void SetCulture()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        }

        private static char[] ReadChars(int n)
        {
            char[] buffer = new char[n];
            Console.In.ReadBlock(buffer, 0, n);
            return buffer;
        }

        private static string[] ReadAll()
        {
            return Console.In.ReadToEnd().Split(new char[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] ReadWords(char[] splitter)
        {
            return Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] ReadWords()
        {
            return ReadWords(_defaultSplitter);
        }

        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        private static int[] ReadInts(char[] splitter)
        {
            return Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        private static int[] ReadInts()
        {
            return ReadInts(_defaultSplitter);
        }

        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        private static double ReadDouble()
        {
            return double.Parse(Console.ReadLine(), NumberFormatInfo.InvariantInfo);
        }

        private static int _pos = 0;
        private static string[] _inputLine = new string[0];

        private static void CheckInputLine()
        {
            if (_pos >= _inputLine.Length)
            {
                _inputLine = ReadWords();
                _pos = 0;
            }
        }

        private static string NextWord()
        {
            CheckInputLine();
            return _inputLine[_pos++];
        }

        private static int NextInt()
        {
            CheckInputLine();
            return int.Parse(_inputLine[_pos++]);
        }

        private static long NextLong()
        {
            CheckInputLine();
            return long.Parse(_inputLine[_pos++]);
        }
    }
}


using System;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.Linq;

namespace Codeforces.R303
{
    public static class B
    {
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            Contract.Requires(tr != null);
            Contract.Requires(tw != null);

            tw.WriteLine(Parse(tr));
        }

        private static string Parse(TextReader tr)
        {
            var info = CultureInfo.CurrentCulture;
            var l = tr.ReadLine().Split().Select(x => int.Parse(x, info)).ToArray();

            return Calc(l[0], l[1], l[2], l[3], l[4], l[5]);
        }

        public static string Calc(int n, int m, int x, int y, int a, int b)
        {
            Reduce(ref a, ref b);
            var maxFactor = Math.Min(n / a, m / b);
            var w = a * maxFactor;
            var h = b * maxFactor;

            var x1 = Nearest(n, w, x);
            var y1 = Nearest(m, h, y);

            var x2 = x1 + w;
            var y2 = y1 + h;

            return $"{x1} {y1} {x2} {y2}";
        }

        public static int Nearest(int n, int w, int x)
        {
            return Math.Max(0, Math.Min(x - (w + 1) / 2, n - w));
        }

        public static void Reduce(ref int a, ref int b)
        {
            var gcd = Gcd(a, b);
            a /= gcd;
            b /= gcd;
        }

        public static int Gcd(int a, int b)
        {
            while (a != 0)
            {
                var r = b % a;
                b = a;
                a = r;
            }
            return b;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeForces
{
    class Prob303B
    {
        //Your task is to find a maximum sub-rectangle on the grid (x1, y1, x2, y2) so that it contains the given point (x, y),
        //and its length-width ratio is exactly (a, b). In other words the following conditions must hold:
        //0 ≤ x1 ≤ x ≤ x2 ≤ n, 0 ≤ y1 ≤ y ≤ y2 ≤ m, (x2-x1)/(y2-y1)=a/b.

        //The sides of this sub-rectangle should be parallel to the axes. And values x1, y1, x2, y2 should be integers.

        //If there are multiple solutions, find the rectangle which is closest to (x, y). Here "closest" means the Euclid
        //distance between (x, y) and the center of the rectangle is as small as possible. If there are still multiple
        //solutions, find the lexicographically minimum one. Here "lexicographically minimum" means that we should consider
        //the sub-rectangle as sequence of integers (x1, y1, x2, y2), so we can choose the lexicographically minimum one.
        class Pair
        {
            int x;
            int y;

            public Pair()
            {
                x = 0;
                y = 0;
            }

            public Pair(int xx, int yy)
            {
                x = xx;
                y = yy;
            }

            public int X
            {
                get { return x; }
                set { x = value; }
            }

            public int Y
            {
                get { return y; }
                set { y = value; }
            }

            public Pair makeBigger(int n)
            {
                return new Pair(x * n, y * n);
            }

            public Pair shift(Pair shiftBy)
            {
                return new Pair(x + shiftBy.X, y + shiftBy.Y);
            }

            public Pair simplify()
            {
                int a = x;
                int b = y;
                int rem;

                while (b != 0)
                {
                    rem = a % b;
                    a = b;
                    b = rem;
                }
                return new Pair(x / a, y / a);
            }

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

        class Rectangle
        {
            Pair bottomLeft;
            Pair upperRight;
            int width;
            int height;

            public Rectangle()
            {
                bottomLeft = new Pair();
                upperRight = new Pair();
                width = 0;
                height = 0;
            }

            public Rectangle(Pair bl, Pair ur)
            {
                bottomLeft = bl;
                upperRight = ur;
                width = upperRight.X - bottomLeft.X;
                height = upperRight.Y - bottomLeft.Y;
            }

            public Pair getLargestFit(Pair ratio)
            {
                Pair p = new Pair(ratio.X, ratio.Y);
                int max = Math.Min(width / p.X, height / p.Y);
                int min = 1;
                int mid;
                while (max > min)
                {
                    mid = min + (max - min) / 2;
                    if (p.X * mid > width || p.Y * mid > height)
                    {
                        max = mid - 1;
                    }
                    else if (mid == min)
                    {
                        min = max;
                    }
                    else
                    {
                        min = mid;
                    }
                }
                return p.makeBigger(min);
            }

            public Rectangle getClosestRectangle(Pair point, Pair dims)
            {
                Pair bottomLeftCorner = new Pair();

                bottomLeftCorner.X = point.X - (dims.X / 2) - (dims.X & 1);
                if (bottomLeftCorner.X < 0)
                {
                    bottomLeftCorner.X = 0;
                }
                else if (bottomLeftCorner.X + dims.X > width)
                {
                    bottomLeftCorner.X = width - dims.X;
                }

                bottomLeftCorner.Y = point.Y - (dims.Y / 2) - (dims.Y & 1);
                if (bottomLeftCorner.Y < 0)
                {
                    bottomLeftCorner.Y = 0;
                }
                else if (bottomLeftCorner.Y + dims.Y > height)
                {
                    bottomLeftCorner.Y = width - dims.Y;
                }

                return new Rectangle(bottomLeftCorner, bottomLeftCorner.shift(dims));
            }

            public override String ToString()
            {
                return bottomLeft.ToString() + " " + upperRight.ToString();
            }
        }

        Rectangle housing;
        Pair point;
        Pair ratio;

        public Prob303B(int n, int m, int x, int y, int a, int b)
        {
            housing = new Rectangle(new Pair(0, 0), new Pair(n, m));
            point = new Pair(x, y);
            ratio = new Pair(a, b);
        }

        public String solve()
        {
            Pair rectDims = housing.getLargestFit(ratio.simplify());
            Rectangle result = housing.getClosestRectangle(point, rectDims);
            return result.ToString();
        }

        public override String ToString()
        {
            return housing.ToString() + " " + point.ToString() + " " + ratio.ToString();
        }

        static void Main(string[] args)
        {
            String line = Console.ReadLine();
            String[] temp = line.Split(' ');
            int[] vals = new int[temp.Length];
            for (int i = 0; i < vals.Length; ++i)
            {
                vals[i] = Convert.ToInt32(temp[i]);
            }
            Prob303B prob = new Prob303B(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5]);
            Console.WriteLine(prob.solve());
        }
    }
}