#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;

using ll = long long;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char c) {
  return string(1,c);
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (int i = int(N)-1; i >= 0; --i) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef COMPETITIVE_PROGRAMMING_LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) if(0){}
#endif

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

struct Scanner {
  int fd = -1;
  char line[(1 << 15) + 1];
  size_t st = 0, ed = 0;
  void reread() {
    memmove(line, line + st, ed - st);
    ed -= st;
    st = 0;
    ed += ::read(fd, line + ed, (1 << 15) - ed);
    line[ed] = '\0';
  }
  bool succ() {
    while (true) {
      if (st == ed) {
        reread();
        if (st == ed) return false;
      }
      while (st != ed && isspace(line[st])) st++;
      if (st != ed) break;
    }
    if (ed - st <= 50) {
      bool sep = false;
      for (size_t i = st; i < ed; i++) {
        if (isspace(line[i])) {
          sep = true;
          break;
        }
      }
      if (!sep) reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
  bool read_single(T& ref) {
    if (!succ()) return false;
    while (true) {
      size_t sz = 0;
      while (st + sz < ed && !isspace(line[st + sz])) sz++;
      ref.append(line + st, sz);
      st += sz;
      if (!sz || st != ed) break;
      reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  bool read_single(T& ref) {
    if (!succ()) return false;
    bool neg = false;
    if (line[st] == '-') {
      neg = true;
      st++;
    }
    ref = T(0);
    while (isdigit(line[st])) {
      ref = 10 * ref + (line[st++] & 0xf);
    }
    if (neg) ref = -ref;
    return true;
  }
  template <class T> bool read_single(V<T>& ref) {
    for (auto& d : ref) {
      if (!read_single(d)) return false;
    }
    return true;
  }
  template <class T> bool read_single(array<T,2>& ref) {
    if (!read_single(ref[0])) return false;
    if (!read_single(ref[1])) return false;
    return true;
  }
  template <class T> bool read_single(array<T,3>& ref) {
    if (!read_single(ref[0])) return false;
    if (!read_single(ref[1])) return false;
    if (!read_single(ref[2])) return false;
    return true;
  }
  template <class T> bool read_single(array<T,4>& ref) {
    if (!read_single(ref[0])) return false;
    if (!read_single(ref[1])) return false;
    if (!read_single(ref[2])) return false;
    if (!read_single(ref[3])) return false;
    return true;
  }
  void read() {}
  template <class H, class... T> void read(H& h, T&... t) {
    bool f = read_single(h);
    assert(f);
    read(t...);
  }
  Scanner(FILE* fp) : fd(fileno(fp)) {}
};

struct Printer {
public:
  template <bool F = false> void write() {}
  template <bool F = false, class H, class... T>
  void write(const H& h, const T&... t) {
    if (F) write_single(' ');
    write_single(h);
    write<true>(t...);
  }
  template <class... T> void writeln(const T&... t) {
    write(t...);
    write_single('\n');
  }

  Printer(FILE* _fp) : fp(_fp) {}
  ~Printer() { flush(); }

private:
  static constexpr size_t SIZE = 1 << 15;
  FILE* fp;
  char line[SIZE], small[50];
  size_t pos = 0;
  void flush() {
    fwrite(line, 1, pos, fp);
    pos = 0;
  }
  void write_single(const char& val) {
    if (pos == SIZE) flush();
    line[pos++] = val;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  void write_single(T val) {
    if (pos > (1 << 15) - 50) flush();
    if (val == 0) {
      write_single('0');
      return;
    }
    if (val < 0) {
      write_single('-');
      val = -val; // todo min
    }
    size_t len = 0;
    while (val) {
      small[len++] = char(0x30 | (val % 10));
      val /= 10;
    }
    for (size_t i = 0; i < len; i++) {
      line[pos + i] = small[len - 1 - i];
    }
    pos += len;
  }
  void write_single(const string& s) {
    for (char c : s) write_single(c);
  }
  void write_single(const char* s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++) write_single(s[i]);
  }
  template <class T> void write_single(const V<T>& val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write_single(' ');
      write_single(val[i]);
    }
  }
};

Scanner sc = Scanner(stdin);
Printer pr = Printer(stdout);
#define int ll

ll GetK(ll sum) {
  ll l = 0, r = sum+1;
  while (r-l > 1) {
    ll m = l + (r-l)/2;
    if (m*(m+1)/2 <= sum) {
      l = m;
    } else {
      r = m;
    }
  }
  return l;
}

int32_t main() {
  ios::sync_with_stdio(0); cin.tie(0);

  ll a,b;
  sc.read(a,b);
  ll k = GetK(a+b);
  ll ok = k;
//  dbg(k);
  vector<int> A;
  while (a >= k && k >= 1) {
    A.push_back(k);
    a -= k--;
  }
  if (a >= 1 && a <= k) {
    // dbg(a,k,ok);
    assert(a <= k);
    A.push_back(a);
  }
#ifndef COMPETITIVE_PROGRAMMING_LOCAL
  pr.writeln(A.size());
  pr.writeln(A);
#endif
  int sz = A.size();
//  dbg(A.size());
  auto half = A;
  A.clear();

  for (int i = 1; i <= k; ++i) {
    if (i == a) continue;
    if (i > b) break;
    A.push_back(i);
    b -= i;
  }
  assert(A.size()+sz+1 >= ok);
#ifdef COMPETITIVE_PROGRAMMING_LOCAL
  set<int> s_half(half.begin(),half.end());
  set<int> A_half(A.begin(),A.end());
  set<int> both(A.begin(),A.end());
  for (int aa : s_half) both.insert(aa);
  assert(both.size() == s_half.size() + A_half.size());

#endif
//  dbg(A.size());

#ifndef COMPETITIVE_PROGRAMMING_LOCAL
  pr.writeln(A.size());
  pr.writeln(A);
#endif
}


#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;

using ll = long long;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char c) {
  return string(1,c);
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (int i = int(N)-1; i >= 0; --i) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef COMPETITIVE_PROGRAMMING_LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) if(0){}
#endif

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

struct Scanner {
  int fd = -1;
  char line[(1 << 15) + 1];
  size_t st = 0, ed = 0;
  void reread() {
    memmove(line, line + st, ed - st);
    ed -= st;
    st = 0;
    ed += ::read(fd, line + ed, (1 << 15) - ed);
    line[ed] = '\0';
  }
  bool succ() {
    while (true) {
      if (st == ed) {
        reread();
        if (st == ed) return false;
      }
      while (st != ed && isspace(line[st])) st++;
      if (st != ed) break;
    }
    if (ed - st <= 50) {
      bool sep = false;
      for (size_t i = st; i < ed; i++) {
        if (isspace(line[i])) {
          sep = true;
          break;
        }
      }
      if (!sep) reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
  bool read_single(T& ref) {
    if (!succ()) return false;
    while (true) {
      size_t sz = 0;
      while (st + sz < ed && !isspace(line[st + sz])) sz++;
      ref.append(line + st, sz);
      st += sz;
      if (!sz || st != ed) break;
      reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  bool read_single(T& ref) {
    if (!succ()) return false;
    bool neg = false;
    if (line[st] == '-') {
      neg = true;
      st++;
    }
    ref = T(0);
    while (isdigit(line[st])) {
      ref = 10 * ref + (line[st++] & 0xf);
    }
    if (neg) ref = -ref;
    return true;
  }
  template <class T> bool read_single(V<T>& ref) {
    for (auto& d : ref) {
      if (!read_single(d)) return false;
    }
    return true;
  }
  template <class T> bool read_single(array<T,2>& ref) {
    if (!read_single(ref[0])) return false;
    if (!read_single(ref[1])) return false;
    return true;
  }
  template <class T> bool read_single(array<T,3>& ref) {
    if (!read_single(ref[0])) return false;
    if (!read_single(ref[1])) return false;
    if (!read_single(ref[2])) return false;
    return true;
  }
  template <class T> bool read_single(array<T,4>& ref) {
    if (!read_single(ref[0])) return false;
    if (!read_single(ref[1])) return false;
    if (!read_single(ref[2])) return false;
    if (!read_single(ref[3])) return false;
    return true;
  }
  void read() {}
  template <class H, class... T> void read(H& h, T&... t) {
    bool f = read_single(h);
    assert(f);
    read(t...);
  }
  Scanner(FILE* fp) : fd(fileno(fp)) {}
};

struct Printer {
public:
  template <bool F = false> void write() {}
  template <bool F = false, class H, class... T>
  void write(const H& h, const T&... t) {
    if (F) write_single(' ');
    write_single(h);
    write<true>(t...);
  }
  template <class... T> void writeln(const T&... t) {
    write(t...);
    write_single('\n');
  }

  Printer(FILE* _fp) : fp(_fp) {}
  ~Printer() { flush(); }

private:
  static constexpr size_t SIZE = 1 << 15;
  FILE* fp;
  char line[SIZE], small[50];
  size_t pos = 0;
  void flush() {
    fwrite(line, 1, pos, fp);
    pos = 0;
  }
  void write_single(const char& val) {
    if (pos == SIZE) flush();
    line[pos++] = val;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  void write_single(T val) {
    if (pos > (1 << 15) - 50) flush();
    if (val == 0) {
      write_single('0');
      return;
    }
    if (val < 0) {
      write_single('-');
      val = -val; // todo min
    }
    size_t len = 0;
    while (val) {
      small[len++] = char(0x30 | (val % 10));
      val /= 10;
    }
    for (size_t i = 0; i < len; i++) {
      line[pos + i] = small[len - 1 - i];
    }
    pos += len;
  }
  void write_single(const string& s) {
    for (char c : s) write_single(c);
  }
  void write_single(const char* s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++) write_single(s[i]);
  }
  template <class T> void write_single(const V<T>& val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write_single(' ');
      write_single(val[i]);
    }
  }
};

Scanner sc = Scanner(stdin);
Printer pr = Printer(stdout);
#define int ll

ll GetK(ll sum) {
  ll l = 0, r = sum+1;
  while (r-l > 1) {
    ll m = l + (r-l)/2;
    if (m*(m+1)/2 <= sum) {
      l = m;
    } else {
      r = m;
    }
  }
  return l;
}

int32_t main() {
  ios::sync_with_stdio(0); cin.tie(0);

  ll a,b;
  sc.read(a,b);
  ll k = GetK(a+b);
  ll ok = k;
//  dbg(k);
  vector<int> A;
  while (a >= k && k >= 1) {
    A.push_back(k);
    a -= k--;
  }
  if (a >= 1) {
    A.push_back(a);
  }
#ifndef COMPETITIVE_PROGRAMMING_LOCAL
  pr.writeln(A.size());
  pr.writeln(A);
#endif
  int sz = A.size();
//  dbg(A.size());
  A.clear();

  for (int i = 1; i <= k; ++i) {
    if (i == a) continue;
    if (i > b) break;
    A.push_back(i);
    b -= i;
  }
  assert(A.size()+sz+1 >= ok);

//  dbg(A.size());

#ifndef COMPETITIVE_PROGRAMMING_LOCAL
  pr.writeln(A.size());
  pr.writeln(A);
#endif
}


#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;

using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

struct Scanner {
  int fd = -1;
  char line[(1 << 15) + 1];
  size_t st = 0, ed = 0;
  void reread() {
    memmove(line, line + st, ed - st);
    ed -= st;
    st = 0;
    ed += ::read(fd, line + ed, (1 << 15) - ed);
    line[ed] = '\0';
  }
  bool succ() {
    while (true) {
      if (st == ed) {
        reread();
        if (st == ed) return false;
      }
      while (st != ed && isspace(line[st])) st++;
      if (st != ed) break;
    }
    if (ed - st <= 50) {
      bool sep = false;
      for (size_t i = st; i < ed; i++) {
        if (isspace(line[i])) {
          sep = true;
          break;
        }
      }
      if (!sep) reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
  bool read_single(T& ref) {
    if (!succ()) return false;
    while (true) {
      size_t sz = 0;
      while (st + sz < ed && !isspace(line[st + sz])) sz++;
      ref.append(line + st, sz);
      st += sz;
      if (!sz || st != ed) break;
      reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  bool read_single(T& ref) {
    if (!succ()) return false;
    bool neg = false;
    if (line[st] == '-') {
      neg = true;
      st++;
    }
    ref = T(0);
    while (isdigit(line[st])) {
      ref = 10 * ref + (line[st++] & 0xf);
    }
    if (neg) ref = -ref;
    return true;
  }
  template <class T> bool read_single(V<T>& ref) {
    for (auto& d : ref) {
      if (!read_single(d)) return false;
    }
    return true;
  }
  template <class T> bool read_single(array<T,2>& ref) {
    if (!read_single(ref[0])) return false;
    if (!read_single(ref[1])) return false;
    return true;
  }
  template <class T> bool read_single(array<T,3>& ref) {
    if (!read_single(ref[0])) return false;
    if (!read_single(ref[1])) return false;
    if (!read_single(ref[2])) return false;
    return true;
  }
  template <class T> bool read_single(array<T,4>& ref) {
    if (!read_single(ref[0])) return false;
    if (!read_single(ref[1])) return false;
    if (!read_single(ref[2])) return false;
    if (!read_single(ref[3])) return false;
    return true;
  }
  void read() {}
  template <class H, class... T> void read(H& h, T&... t) {
    bool f = read_single(h);
    assert(f);
    read(t...);
  }
  Scanner(FILE* fp) : fd(fileno(fp)) {}
};

struct Printer {
public:
  template <bool F = false> void write() {}
  template <bool F = false, class H, class... T>
  void write(const H& h, const T&... t) {
    if (F) write_single(' ');
    write_single(h);
    write<true>(t...);
  }
  template <class... T> void writeln(const T&... t) {
    write(t...);
    write_single('\n');
  }

  Printer(FILE* _fp) : fp(_fp) {}
  ~Printer() { flush(); }

private:
  static constexpr size_t SIZE = 1 << 15;
  FILE* fp;
  char line[SIZE], small[50];
  size_t pos = 0;
  void flush() {
    fwrite(line, 1, pos, fp);
    pos = 0;
  }
  void write_single(const char& val) {
    if (pos == SIZE) flush();
    line[pos++] = val;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  void write_single(T val) {
    if (pos > (1 << 15) - 50) flush();
    if (val == 0) {
      write_single('0');
      return;
    }
    if (val < 0) {
      write_single('-');
      val = -val; // todo min
    }
    size_t len = 0;
    while (val) {
      small[len++] = char(0x30 | (val % 10));
      val /= 10;
    }
    for (size_t i = 0; i < len; i++) {
      line[pos + i] = small[len - 1 - i];
    }
    pos += len;
  }
  void write_single(const string& s) {
    for (char c : s) write_single(c);
  }
  void write_single(const char* s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++) write_single(s[i]);
  }
  template <class T> void write_single(const V<T>& val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write_single(' ');
      write_single(val[i]);
    }
  }
};

Scanner sc = Scanner(stdin);
Printer pr = Printer(stdout);
#define int ll

ll GetK(ll sum) {
  ll l = -1, r = sum+1;
  while (r-l > 1) {
    ll m = l + (r-l)/2;
    if (m*(m+1)/2 <= sum) {
      l = m;
    } else {
      r = m;
    }
  }
  return l;
}
int32_t main() {
  ios::sync_with_stdio(0); cin.tie(0);

  ll a,b;
  sc.read(a,b);
  ll sum = a+b;
  ll k = GetK(sum);
  vector<int> A,B;
  while (a >= k) {
    A.push_back(k);
    a -= k--;
  }
  if (a >= 1) {
    A.push_back(a);
  }
  for (int i = 1; i <= k; ++i) {
    if (i == a) continue;
    if (i > b) break;
    B.push_back(i);
    b -= i;
  }
  pr.writeln(A.size());
  pr.writeln(A);
  pr.writeln(B.size());
  pr.writeln(B);

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int a,b; cin>>a>>b;
    int s=0,m=0,h=0; vector<int>d1,d2;
    while(s<a)
    {
        m++;
        s=m*(m+1);s/=2;
    }
    int del=s-a,sd=0;
    for(int i=1;i<=m;i++)
    {
        if(i==del) {if(b>=i){ b-=i;d2.push_back(i);}}
        else
        {
            d1.push_back(i);
            h=max(h,i);
        }
    } h++;
    while(b>=h)
    {
        b-=h;
        d2.push_back(h); h++;
    }
    cout<<d1.size()<<endl;
    for(auto i:d1) cout<<i<<" "; cout<<endl;
    cout<<d2.size()<<endl;
    for(auto i:d2) cout<<i<<" "; cout<<endl;
}

int main(){
   int t=1;
   //cin>>t;
   while(t--){
   solve();
   cout<<endl;
   }
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int a,b; cin>>a>>b;// if(a<b) swap(a,b);
    int s=1,m=0,h=0; vector<int>d1,d2;
    while(s<a)
    {
        m++;
        s=m*(m+1);s/=2;
    }
    int del=s-a,sd=0;
    for(int i=1;i<=m;i++)
    {
        if(i==del) { d2.push_back(i); if(b>=i)b-=i;}
        else
        {
            d1.push_back(i);
            h=max(h,i);
        }
    } h++;
    while(b>=h)
    {
        b-=h;
        d2.push_back(h); h++;
    }
    cout<<d1.size()<<endl;
    for(auto i:d1) cout<<i<<" "; cout<<endl;
    cout<<d2.size()<<endl;
    for(auto i:d2) cout<<i<<" "; cout<<endl;
}

int main(){
   int t=1;
   //cin>>t;
   while(t--){
   solve();
   cout<<endl;
   }
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int a,b; cin>>a>>b;  int f=1;if(a<b) { swap(a,b); f=0;}
    int s=1,m=0,h=0; vector<int>d1,d2;
    while(s<a)
    {
        m++;
        s=m*(m+1);s/=2;
    }
    int del=s-a,sd=0;
    for(int i=1;i<=m;i++)
    {
        if(i==del) { d2.push_back(i); if(b>=i)b-=i;}
        else
        {
            d1.push_back(i);
            h=max(h,i);
        }
    } h++;
    while(b>=h)
    {
        b-=h;
        d2.push_back(h); h++;
    }
    if(f){
    cout<<d1.size()<<endl;
    for(auto i:d1) cout<<i<<" "; cout<<endl;
    cout<<d2.size()<<endl;
    for(auto i:d2) cout<<i<<" "; cout<<endl;}
    else
    {
    cout<<d2.size()<<endl;
    for(auto i:d2) cout<<i<<" "; cout<<endl;
    cout<<d1.size()<<endl;
    for(auto i:d1) cout<<i<<" "; cout<<endl;
    }
}

int main(){
   int t=1;
   //cin>>t;
   while(t--){
   solve();
   cout<<endl;
   }
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int a,b; cin>>a>>b;
    int s=0,m=0,h=0; vector<int>d1,d2;
    while(s<a)
    {
        m++;
        s=m*(m+1);s/=2;
    }
    int del=s-a,sd=0;
    for(int i=1;i<=m;i++)
    {
        if(i==del) { d2.push_back(i); if(b>=i)b-=i;}
        else
        {
            d1.push_back(i);
            h=max(h,i);
        }
    } h++;
    while(b>=h)
    {
        b-=h;
        d2.push_back(h); h++;
    }
    cout<<d1.size()<<endl;
    for(auto i:d1) cout<<i<<" "; cout<<endl;
    cout<<d2.size()<<endl;
    for(auto i:d2) cout<<i<<" "; cout<<endl;
}

int main(){
   int t=1;
   //cin>>t;
   while(t--){
   solve();
   cout<<endl;
   }
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int a,b; cin>>a>>b;// if(a<b) swap(a,b);
    int s=1,m=1,h=0; vector<int>d1,d2;
    while(s<a)
    {
        m++;
        s=m*(m+1);s/=2;
    }
    int del=s-a,sd=0;
    for(int i=1;i<=m;i++)
    {
        if(i==del) { d2.push_back(i); if(b>=i)b-=i;}
        else
        {
            d1.push_back(i);
            h=max(h,i);
        }
    } h++;
    while(b>=h)
    {
        b-=h;
        d2.push_back(h); h++;
    }
    cout<<d1.size()<<endl;
    for(auto i:d1) cout<<i<<" "; cout<<endl;
    cout<<d2.size()<<endl;
    for(auto i:d2) cout<<i<<" "; cout<<endl;
}

int main(){
   int t=1;
   //cin>>t;
   while(t--){
   solve();
   cout<<endl;
   }
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int a,b; cin>>a>>b; if(a<b) swap(a,b);
    int s=1,m=1,h=0; vector<int>d1,d2;
    while(s<a)
    {
        m++;
        s=m*(m+1);s/=2;
    }
    int del=s-a,sd=0;
    for(int i=1;i<=m;i++)
    {
        if(i==del) { d2.push_back(i); if(b>=i)b-=i;}
        else
        {
            d1.push_back(i);
            h=max(h,i);
        }
    } h++;
    while(b>=h)
    {

        d2.push_back(h); h++;
    }
    cout<<d1.size()<<endl;
    for(auto i:d1) cout<<i<<" "; cout<<endl;
    cout<<d2.size()<<endl;
    for(auto i:d2) cout<<i<<" "; cout<<endl;
}

int main(){
   int t=1;
   //cin>>t;
   while(t--){
   solve();
   cout<<endl;
   }
   return 0;
}


#include <bits/stdc++.h>
    #define FILES /*freopen("crypt.in", "r", stdin);*/  freopen("input.txt", "w", stdout)
    #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define FIXED cout << fixed << setprecision(20)
    #define pb push_back
    #define pf push_front
    #define eps 1e-9
    #define mod pow(10,8)
    #define f first
    #define s second

    using namespace std;

    typedef long long ll;
    typedef pair<ll, ll> pll;
    typedef long double ld;
    typedef vector <vector<ll> > graf;
    typedef pair< ld, ld> pld;
    const ll N=1000000;
    int main(){
    FAST;
     ll a,b;
     cin>>a>>b;
     vector<ll> t,t2;
     vector<ll> x(N+1,0);
      if(a==0 && b==0){
        cout<<0<<endl<<0<<endl; return 0;
      }
     if(a<b){
     if(a!=1){
     for(ll i=1; i<=a; i++){
     if(i*(i+1)>2*a) {a-=((i-1)*i/2); break;}
     t.pb(i);
     }
     if(a>0){
     t[t.size()-1]+=a;
     }
     a=0;}
     else {t.pb(1); x[1]=1;}
     cout<<t.size()<<endl;
     for(ll i=0; i<t.size(); i++) {cout<<t[i]<<' ';  a+=t[i];
     x[t[i]]=1;}
     cout<<endl;
     // cout<<a;
     ll r=0;
     for(ll i=1; i<=b; i++){
            //cout<<i*(i+1)/2-a<<' ';
      if(x[i]==1) r+=i;
     if(i*(i+1)/2-r>b) {b-=((i-1)*i/2-r); break;}
     if(x[i]!=1) t2.pb(i);
     }

     cout<<t2.size()<<endl;
     for(ll i=0; i<t2.size(); i++){
        cout<<t2[i]<<' ';
     }
     return 0;
     }

      swap(a,b);
     if(a!=1){
     for(ll i=1; i<=a; i++){
           //cout<<i<<endl;
     if(i*(i+1)>2*a) {a-=((i-1)*i/2); x[i-1]=0; break;}
     t.pb(i); x[i]=1;
     }
     if(a>0){
     t[t.size()-1]+=a;
     }
     x[t[t.size()-1]]=1;
     a=0;
     }
     else {x[1]=1; t.pb(1);}
     // cout<<a;
     ll r=0;
     for(ll i=1; i<=b; i++){
            //cout<<i*(i+1)/2-a<<' ';
      if(x[i]==1) r+=i;
     if(i*(i+1)/2-r>b) {b-=((i-1)*i/2-r); break;}
     if(x[i]!=1) t2.pb(i);
     }

     cout<<t2.size()<<endl;
     for(ll i=0; i<t2.size(); i++){
        cout<<t2[i]<<' ';
     }
     cout<<endl;
     cout<<t.size()<<endl;
     for(ll i=0; i<t.size(); i++) {cout<<t[i]<<' ';
     x[t[i]]=1;}
     }


#include <bits/stdc++.h>
    #define FILES /*freopen("crypt.in", "r", stdin);*/  freopen("input.txt", "w", stdout)
    #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define FIXED cout << fixed << setprecision(20)
    #define pb push_back
    #define pf push_front
    #define eps 1e-9
    #define mod pow(10,8)
    #define f first
    #define s second

    using namespace std;

    typedef long long ll;
    typedef pair<ll, ll> pll;
    typedef long double ld;
    typedef vector <vector<ll> > graf;
    typedef pair< ld, ld> pld;
    const ll N=1000000;
    int main(){
    FAST;
     ll a,b;
    cin>>a>>b;
    vector<ll> ta,tb;
    ll x=0;
    for(ll i=1; i<=a+b+100; i++){
    x=i;
    if((x+1)*(x+2)/2>a+b) {break;}
    }
    for(ll i=x; i>=1; i--){
    if(a>b){
    if(b>=i){tb.pb(i); b-=i;}
    else if(a>=i) {ta.pb(i); a-=i;}

    }
    else{
    if(a>=i){ta.pb(i); a-=i;}
    else if(b>=i) {tb.pb(i); b-=i;}
    }

    }
    sort(ta.begin(),ta.end());
    sort(tb.begin(),tb.end());
    cout<<ta.size()<<endl;
    for(ll i=0; i<ta.size(); i++){
     cout<<ta[i]<<' ';
    }
    cout<<endl;
    cout<<tb.size()<<endl;
    for(ll i=0; i<tb.size(); i++){
        cout<<tb[i]<<' ';
    }

     }


#include <bits/stdc++.h>
    #define FILES /*freopen("crypt.in", "r", stdin);*/  freopen("input.txt", "w", stdout)
    #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define FIXED cout << fixed << setprecision(20)
    #define pb push_back
    #define pf push_front
    #define eps 1e-9
    #define mod pow(10,8)
    #define f first
    #define s second

    using namespace std;

    typedef long long ll;
    typedef pair<ll, ll> pll;
    typedef long double ld;
    typedef vector <vector<ll> > graf;
    typedef pair< ld, ld> pld;
    const ll N=1000000;
    int main(){
    FAST;
     ll a,b;
     cin>>a>>b;
     vector<ll> t,t2;
     vector<ll> x(N+1,0);

     if(a<b){
     if(a!=1){
     for(ll i=1; i<=a; i++){
     if(i*(i+1)>2*a) {a-=((i-1)*i/2); break;}
     t.pb(i);
     }
     if(a>0){
     t[t.size()-1]+=a;
     }
     a=0;}
     else {t.pb(1); x[1]=1;}
     cout<<t.size()<<endl;
     for(ll i=0; i<t.size(); i++) {cout<<t[i]<<' ';  a+=t[i];
     x[t[i]]=1;}
     cout<<endl;
     // cout<<a;
     ll r=0;
     for(ll i=1; i<=b; i++){
            //cout<<i*(i+1)/2-a<<' ';
      if(x[i]==1) r+=i;
     if(i*(i+1)/2-r>b) {b-=((i-1)*i/2-r); break;}
     if(x[i]!=1) t2.pb(i);
     }

     cout<<t2.size()<<endl;
     for(ll i=0; i<t2.size(); i++){
        cout<<t2[i]<<' ';
     }
     }

      if(a>=b){
      swap(a,b);
     if(a!=1){
     for(ll i=1; i<=a; i++){
           //cout<<i<<endl;
     if(i*(i+1)>2*a) {a-=((i-1)*i/2); x[i-1]=0; break;}
     t.pb(i); x[i]=1;
     }
     if(a>0){
     t[t.size()-1]+=a;
     }
     x[t[t.size()-1]]=1;
     a=0;
     }
     else {x[1]=1; t.pb(1);}
     // cout<<a;
     ll r=0;
     for(ll i=1; i<=b; i++){
            //cout<<i*(i+1)/2-a<<' ';
      if(x[i]==1) r+=i;
     if(i*(i+1)/2-r>b) {b-=((i-1)*i/2-r); break;}
     if(x[i]!=1) t2.pb(i);
     }

     cout<<t2.size()<<endl;
     for(ll i=0; i<t2.size(); i++){
        cout<<t2[i]<<' ';
     }
     cout<<endl;
     cout<<t.size()<<endl;
     for(ll i=0; i<t.size(); i++) {cout<<t[i]<<' ';
     x[t[i]]=1;}
     }

    }


#include <bits/stdc++.h>
    #define FILES /*freopen("crypt.in", "r", stdin);*/  freopen("input.txt", "w", stdout)
    #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define FIXED cout << fixed << setprecision(20)
    #define pb push_back
    #define pf push_front
    #define eps 1e-9
    #define mod pow(10,8)
    #define f first
    #define s second

    using namespace std;

    typedef long long ll;
    typedef pair<ll, ll> pll;
    typedef long double ld;
    typedef vector <vector<ll> > graf;
    typedef pair< ld, ld> pld;
    const ll N=1000000;
    int main(){
    FAST;
     ll a,b;
     cin>>a>>b;
     vector<ll> t,t2;
     vector<ll> x(N+1,0);

     if(a<b){
     if(a!=1){
     for(ll i=1; i<=a; i++){
     if(i*(i+1)>2*a) {a-=((i-1)*i/2); break;}
     t.pb(i);
     }
     if(a>0){
     t[t.size()-1]+=a;
     }
     a=0;}
     else {t.pb(1); x[1]=1;}
     cout<<t.size()<<endl;
     for(ll i=0; i<t.size(); i++) {cout<<t[i]<<' ';  a+=t[i];
     x[t[i]]=1;}
     cout<<endl;
     // cout<<a;
     ll r=0;
     for(ll i=1; i<=b; i++){
            //cout<<i*(i+1)/2-a<<' ';
      if(x[i]==1) r+=i;
     if(i*(i+1)/2-r>b) {b-=((i-1)*i/2-r); break;}
     if(x[i]!=1) t2.pb(i);
     }

     cout<<t2.size()<<endl;
     for(ll i=0; i<t2.size(); i++){
        cout<<t2[i]<<' ';
     }
     return 0;
     }

      if(a>=b){
      swap(a,b);
     if(a!=1){
     for(ll i=1; i<=a; i++){
           //cout<<i<<endl;
     if(i*(i+1)>2*a) {a-=((i-1)*i/2); x[i-1]=0; break;}
     t.pb(i); x[i]=1;
     }
     if(a>0){
     t[t.size()-1]+=a;
     }
     x[t[t.size()-1]]=1;
     a=0;
     }
     else {x[1]=1; t.pb(1);}
     // cout<<a;
     ll r=0;
     for(ll i=1; i<=b; i++){
            //cout<<i*(i+1)/2-a<<' ';
      if(x[i]==1) r+=i;
     if(i*(i+1)/2-r>b) {b-=((i-1)*i/2-r); break;}
     if(x[i]!=1) t2.pb(i);
     }

     cout<<t2.size()<<endl;
     for(ll i=0; i<t2.size(); i++){
        cout<<t2[i]<<' ';
     }
     cout<<endl;
     cout<<t.size()<<endl;
     for(ll i=0; i<t.size(); i++) {cout<<t[i]<<' ';
     x[t[i]]=1;}
     }

    }


#include <bits/stdc++.h>
    #define FILES /*freopen("crypt.in", "r", stdin);*/  freopen("input.txt", "w", stdout)
    #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define FIXED cout << fixed << setprecision(20)
    #define pb push_back
    #define pf push_front
    #define eps 1e-9
    #define mod pow(10,8)
    #define f first
    #define s second

    using namespace std;

    typedef long long ll;
    typedef pair<ll, ll> pll;
    typedef long double ld;
    typedef vector <vector<ll> > graf;
    typedef pair< ld, ld> pld;
    const ll N=1000000;
    int main(){
    FAST;
     ll a,b;
     cin>>a>>b;
     vector<ll> t,t2;
     vector<ll> x(N+1,0);
      if(a==0 && b==0){
        cout<<endl<<endl; return 0;
      }
     if(a<b){
     if(a!=1){
     for(ll i=1; i<=a; i++){
     if(i*(i+1)>2*a) {a-=((i-1)*i/2); break;}
     t.pb(i);
     }
     if(a>0){
     t[t.size()-1]+=a;
     }
     a=0;}
     else {t.pb(1); x[1]=1;}
     cout<<t.size()<<endl;
     for(ll i=0; i<t.size(); i++) {cout<<t[i]<<' ';  a+=t[i];
     x[t[i]]=1;}
     cout<<endl;
     // cout<<a;
     ll r=0;
     for(ll i=1; i<=b; i++){
            //cout<<i*(i+1)/2-a<<' ';
      if(x[i]==1) r+=i;
     if(i*(i+1)/2-r>b) {b-=((i-1)*i/2-r); break;}
     if(x[i]!=1) t2.pb(i);
     }

     cout<<t2.size()<<endl;
     for(ll i=0; i<t2.size(); i++){
        cout<<t2[i]<<' ';
     }
     return 0;
     }

      swap(a,b);
     if(a!=1){
     for(ll i=1; i<=a; i++){
           //cout<<i<<endl;
     if(i*(i+1)>2*a) {a-=((i-1)*i/2); x[i-1]=0; break;}
     t.pb(i); x[i]=1;
     }
     if(a>0){
     t[t.size()-1]+=a;
     }
     x[t[t.size()-1]]=1;
     a=0;
     }
     else {x[1]=1; t.pb(1);}
     // cout<<a;
     ll r=0;
     for(ll i=1; i<=b; i++){
            //cout<<i*(i+1)/2-a<<' ';
      if(x[i]==1) r+=i;
     if(i*(i+1)/2-r>b) {b-=((i-1)*i/2-r); break;}
     if(x[i]!=1) t2.pb(i);
     }

     cout<<t2.size()<<endl;
     for(ll i=0; i<t2.size(); i++){
        cout<<t2[i]<<' ';
     }
     cout<<endl;
     cout<<t.size()<<endl;
     for(ll i=0; i<t.size(); i++) {cout<<t[i]<<' ';
     x[t[i]]=1;}
     }


#include <bits/stdc++.h>
    #define FILES /*freopen("crypt.in", "r", stdin);*/  freopen("input.txt", "w", stdout)
    #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define FIXED cout << fixed << setprecision(20)
    #define pb push_back
    #define pf push_front
    #define eps 1e-9
    #define mod pow(10,8)
    #define f first
    #define s second

    using namespace std;

    typedef long long ll;
    typedef pair<ll, ll> pll;
    typedef long double ld;
    typedef vector <vector<ll> > graf;
    typedef pair< ld, ld> pld;
    const ll N=1000000;
    int main(){
    FAST;
    /*ll n;
    cin>>n;
    vector<ll> a(n+1,0),b(n+1,0);
    for(ll i=1;i<=n;i++) cin>>a[i];
    for(ll i=1; i<=n; i++) cin>>b[i];

    for(ll i=1; i<=n;  i++){

    }

    for(ll i=0; i<=3; i++){
        for(ll j=0; j<=3; j++){
            cout<<i<<' '<<j<<":      "<<(i&j)<<' '<<(i|j)<<endl;
        }
    }*/

     /*
     ll a,b;
     cin>>a>>b;
     vector<ll> t,t2;
     vector<ll> x(N+1,0);
     for(ll i=1; i<=a; i++){
     if(i*(i+1)>2*a) {a-=((i-1)*i/2); break;}
     t.pb(i);
     }
     if(a>0){
     t[t.size()-1]+=a;
     }
     cout<<t.size()<<endl;
     for(ll i=0; i<t.size(); i++) {cout<<t[i]<<' '; x[i]=1;}
     cout<<endl;

     for(ll i=1; i<=b; i++){
     if(i*(i+1)>2*(b+a)) {b-=((i-1)*i/2-a); break;}
     if(x[i]!=1) t.pb(i);
     }
     */

     ll n;
     cin>>n;
     n--;
     vector<ll> a(n+1,0),b(n+1,0);
     for(ll i=1; i<=n; i++){
        cin>>a[i];
     }
     for(ll i=1; i<=n; i++){
        cin>>b[i];
     }

    /* for(ll i=0; i<=3; i++){
        for(ll j=0; j<=3; j++){
            cout<<i<<' '<<j<<":   "<<(i|j)<<' '<<(i&j)<<endl;
        }
      }
     */

      ll p=0;
     vector<ll> t;
     for(ll j=0; j<=3; j++){
            t.resize(n+2,-1);
     t[1]=j;
     for(ll i=1; i<=n; i++){
     //cout<<t[i-1]<<' ';

     if(a[i]==0 && b[i]==0){
        if(t[i]==0){
            t[i+1]=0; continue;
        }
     }
     if(a[i]==1 && b[i]==0){
        if(t[i]==0) {t[i+1]=1; continue;}
        if(t[i]==1) {t[i+1]=0; continue;}
     }
     if(a[i]==2 && b[i]==0){
        if(t[i]==0) {
            t[i+1]=2;
            continue;
        }
        if(t[i]==2) {
            t[i+1]=0; continue;
        }
     }
     if(a[i]==3 && b[i]==0){
        if(t[i]==0){
         t[i+1]=3;
        }
        if(t[i]==1){
         t[i+1]=2;
        }
        if(t[i]==2){
             t[i+1]=1;
        }
        if(t[i]==3){
            t[i+1]=0;
        }
        continue;
     }
     if(a[i]==1 && b[i]==1){
        if(t[i]==1) {t[i+1]=1; continue;}
     }
     //if(a[i]==2 && b[i]==1){}
     if(a[i]==3 && b[i]==1){
        if(t[i]==3) {
           t[i+1]=1; continue;
        }
        if(t[i]==1){
            t[i+1]=3; continue;
        }
     }
     if(a[i]==2 && b[i]==2){
        if(t[i]==2) {t[i+1]=2; continue;}
     }
     if(a[i]==3 && b[i]==2){
         if(t[i]==3) {
           t[i+1]=2; continue;
        }
        if(t[i]==2){
            t[i+1]=3; continue;
        }
     }
     if(a[i]==3 && b[i]==3){
        if(t[i]==3) {t[i+1]=3; continue;}
     }
    // if(a[i]==3 && b[i]==2){}
     //if(a[i]==3 && b[i]==3){}

    break;

     }
     if(t[n+1]!=-1) {p=1; break;}
     }

     if(p==0) {cout<<"NO"; return 0;}
      cout<<"YES"<<endl;

      for(ll i=1; i<=n+1; i++) cout<<t[i]<<' ';

    }


#include <bits/stdc++.h>
    #define FILES /*freopen("crypt.in", "r", stdin);*/  freopen("input.txt", "w", stdout)
    #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define FIXED cout << fixed << setprecision(20)
    #define pb push_back
    #define pf push_front
    #define eps 1e-9
    #define mod pow(10,8)
    #define f first
    #define s second

    using namespace std;

    typedef long long ll;
    typedef pair<ll, ll> pll;
    typedef long double ld;
    typedef vector <vector<ll> > graf;
    typedef pair< ld, ld> pld;
    const ll N=1000000;
    int main(){
    FAST;
     ll a,b;
     cin>>a>>b;
     vector<ll> t,t2;
     vector<ll> x(N+1,0);
      if(a==1 && b==1){
        cout<<1<<endl<<1<<endl; cout<<0<<endl; return 0;
      }
     if(a<b){
     if(a!=1){
     for(ll i=1; i<=a; i++){
     if(i*(i+1)>2*a) {a-=((i-1)*i/2); break;}
     t.pb(i);
     }
     if(a>0){
     t[t.size()-1]+=a;
     }
     a=0;}
     else {t.pb(1); x[1]=1;}
     cout<<t.size()<<endl;
     for(ll i=0; i<t.size(); i++) {cout<<t[i]<<' ';  a+=t[i];
     x[t[i]]=1;}
     cout<<endl;
     // cout<<a;
     ll r=0;
     for(ll i=1; i<=b; i++){
            //cout<<i*(i+1)/2-a<<' ';
      if(x[i]==1) r+=i;
     if(i*(i+1)/2-r>b) {b-=((i-1)*i/2-r); break;}
     if(x[i]!=1) t2.pb(i);
     }

     cout<<t2.size()<<endl;
     for(ll i=0; i<t2.size(); i++){
        cout<<t2[i]<<' ';
     }
     return 0;
     }

      if(a>=b){
      swap(a,b);
     if(a!=1){
     for(ll i=1; i<=a; i++){
           //cout<<i<<endl;
     if(i*(i+1)>2*a) {a-=((i-1)*i/2); x[i-1]=0; break;}
     t.pb(i); x[i]=1;
     }
     if(a>0){
     t[t.size()-1]+=a;
     }
     x[t[t.size()-1]]=1;
     a=0;
     }
     else {x[1]=1; t.pb(1);}
     // cout<<a;
     ll r=0;
     for(ll i=1; i<=b; i++){
            //cout<<i*(i+1)/2-a<<' ';
      if(x[i]==1) r+=i;
     if(i*(i+1)/2-r>b) {b-=((i-1)*i/2-r); break;}
     if(x[i]!=1) t2.pb(i);
     }

     cout<<t2.size()<<endl;
     for(ll i=0; i<t2.size(); i++){
        cout<<t2[i]<<' ';
     }
     cout<<endl;
     cout<<t.size()<<endl;
     for(ll i=0; i<t.size(); i++) {cout<<t[i]<<' ';
     x[t[i]]=1;}
     }

    }


#include <bits/stdc++.h>
    #define FILES /*freopen("crypt.in", "r", stdin);*/  freopen("input.txt", "w", stdout)
    #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define FIXED cout << fixed << setprecision(20)
    #define pb push_back
    #define pf push_front
    #define eps 1e-9
    #define mod pow(10,8)
    #define f first
    #define s second

    using namespace std;

    typedef long long ll;
    typedef pair<ll, ll> pll;
    typedef long double ld;
    typedef vector <vector<ll> > graf;
    typedef pair< ld, ld> pld;
    const ll N=1000000;
    int main(){
    FAST;
     ll a,b;
     cin>>a>>b;
     vector<ll> t,t2;
     vector<ll> x(N+1,0);

     for(ll i=1; i<=a; i++){
     if(i*(i+1)>2*a) {a-=((i-1)*i/2); break;}
     t.pb(i);
     }
     if(a>0){
     t[t.size()-1]+=a;
     }
     a=0;
     cout<<t.size()<<endl;
     for(ll i=0; i<t.size(); i++) {cout<<t[i]<<' ';  a+=t[i];
     x[t[i]]=1;}
     cout<<endl;
     // cout<<a;
     ll r=0;
     for(ll i=1; i<=b; i++){
            //cout<<i*(i+1)/2-a<<' ';
      if(x[i]==1) r+=i;
     if(i*(i+1)/2-r>b) {b-=((i-1)*i/2-r); break;}
     if(x[i]!=1) t2.pb(i);
     }

     cout<<t2.size()<<endl;
     for(ll i=0; i<t2.size(); i++){
        cout<<t2[i]<<' ';
     }

    }


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y))
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
bool flag;
vector<int> vec1, vec2;

int main()
{
	int i, j;
	ll a, b;
	scanf("%lld%lld", &a, &b);
	flag = false;
	if (a > b) {
		swap(a, b);
		flag = true;
	}
	ll l = 1ll;
	ll h = (ll)1e9;
	ll tm = 0ll;
	ll ts = 0ll;
	while (l <= h) {
		ll m = (l + h) >> 1;
		ll s = (ll)((double)(1 + m)*(double)m / 2.0);
		if (s <= a) {
			l = m + 1;
			tm = m;
			ts = s;
		}
		else h = m - 1;
	}
	for (i = 1; i <= tm; ++i) vec1.push_back(i);
	ll need = a - ts;
	ll sum = 0ll;
	if (need == 0) {
		for (i = tm + 1; i; ++i) {
			if (sum + i > b) break;
			sum += (ll)i;
			vec2.push_back(i);
		}
	}
	else {
		for (i = tm; i >= 1; --i) {
			if (!need) {
				break;
			}
			--need;
			vec1[i - 1]++;
		}
		for (i = 1; i; ++i) {
			auto it = lower_bound(vec1.begin(), vec1.end(), i);
			if (it != vec1.end() && *it == i) continue;
			if (sum + i > b) break;
			sum += i;
			vec2.push_back(i);
		}
	}
	if (flag) swap(vec1, vec2);
	printf("%d\n", vec1.size());
	for (i = 0; i < vec1.size(); ++i) {
		printf("%d ", vec1[i]);
		if (i == vec1.size() - 1) printf("\n");
	}
	printf("%d\n", vec2.size());
	for (i = 0; i < vec2.size(); ++i) printf("%d ", vec2[i]);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y))
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
bool flag;
vector<int> vec1, vec2;

int main()
{
	int i, j;
	ll a, b;
	scanf("%lld%lld", &a, &b);
	flag = false;
	if (a > b) {
		swap(a, b);
		flag = true;
	}
	ll l = 1ll;
	ll h = (ll)1e9;
	ll tm = 0ll;
	ll ts = 0ll;
	while (l <= h) {
		ll m = (l + h) >> 1;
		ll s = m * (m + 1ll) / 2;
		if (s <= a) {
			l = m + 1;
			tm = m;
			ts = s;
		}
		else h = m - 1;
	}
	for (i = 1; i <= tm; ++i) vec1.push_back(i);
	ll need = a - ts;
	ll sum = 0ll;
	if (need == 0) {
		for (i = tm + 1; i; ++i) {
			if (sum + i > b) break;
			sum += (ll)i;
			vec2.push_back(i);
		}
	}
	else {
		for (i = tm; i >= 1; --i) {
			if (!need) {
				break;
			}
			--need;
			vec1[i - 1]++;
		}
		for (i = 1; i; ++i) {
			auto it = lower_bound(vec1.begin(), vec1.end(), i);
			if (it != vec1.end() && *it == i) continue;
			if (sum + i > b) break;
			sum += i;
			vec2.push_back(i);
		}
	}
	if (flag) swap(vec1, vec2);
	printf("%d\n", vec1.size());
	for (i = 0; i < vec1.size(); ++i) {
		printf("%d ", vec1[i]);
		if (i == vec1.size() - 1) printf("\n");
	}
	printf("%d\n", vec2.size());
	for (i = 0; i < vec2.size(); ++i) printf("%d ", vec2[i]);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y))
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
vector<int> ans1, ans2;
int maxi;
int cnt;

void check(ll a, ll b) {
	int i;
	vector<int> vec1, vec2;
	ll l = 1ll;
	ll h = (ll)1e9;
	ll tm = 0ll;
	ll ts = 0ll;
	while (l <= h) {
		ll m = (l + h) >> 1;
		ll s = (ll)((double)(1 + m)*(double)m / 2.0);
		if (s <= a) {
			l = m + 1;
			tm = m;
			ts = s;
		}
		else h = m - 1;
	}
	if (a != ts) {
		ll need = a - ts;
		for (i = 1; i < tm; ++i) vec1.push_back(i);
		vec1.push_back(tm + need);
		ll sum = 0ll;
		for (i = tm; i; ++i) {
			if (i == tm + need) continue;
			if (sum + i > b) break;
			sum += i;
			vec2.push_back(i);
		}
	}
	else {
		for (i = 1; i <= tm; ++i) vec1.push_back(i);
		ll sum = 0ll;
		for (i = tm + 1; i; ++i) {
			if (sum + i > b) break;
			sum += i;
			vec2.push_back(i);
		}
	}
	if (vec1.size() + vec2.size() > maxi) {
		maxi = vec1.size() + vec2.size();
		ans1 = vec1;
		ans2 = vec2;
		++cnt;
	}
}

int main()
{
	int i, j;
	ll a, b;
	scanf("%lld%lld", &a, &b);
	maxi = 0;
	cnt = 0;
	check(a, b);
	check(b, a);
	if (cnt == 2) swap(ans1, ans2);

	printf("%d\n", ans1.size());
	for (i = 0; i < ans1.size(); ++i) {
		printf("%d ", ans1[i]);
		if (i == ans1.size() - 1) printf("\n");
	}
	printf("%d\n", ans2.size());
	for (i = 0; i < ans2.size(); ++i) printf("%d ", ans2[i]);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y))
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
vector<int> vec1, vec2;

int main()
{
	int i, j;
	ll a, b;
	scanf("%lld%lld", &a, &b);
	bool flag = false;
	if (a > b) {
		swap(a, b);
		flag = true;
	}
	ll l = 1ll;
	ll h = (ll)1e9;
	ll tm = 0ll;
	ll ts = 0ll;
	while (l <= h) {
		ll m = (l + h) >> 1;
		ll s = (ll)((double)(1 + m)*(double)m / 2.0);
		if (s <= a) {
			l = m + 1;
			tm = m;
			ts = s;
		}
		else h = m - 1;
	}
	if (a != ts) {
		ll need = a - ts;
		for (i = 1; i < tm; ++i) vec1.push_back(i);
		vec1.push_back(tm + need);
		ll sum = 0ll;
		for (i = tm; i; ++i) {
			if (i == tm + need) continue;
			if (sum + i > b) break;
			sum += i;
			vec2.push_back(i);
		}
	}
	else {
		for (i = 1; i <= tm; ++i) vec1.push_back(i);
		ll sum = 0ll;
		for (i = tm + 1; i; ++i) {
			if (sum + i > b) break;
			sum += i;
			vec2.push_back(i);
		}
	}
	if (flag) swap(vec1, vec2);
	printf("%d\n", vec1.size());
	for (i = 0; i < vec1.size(); ++i) {
		printf("%d ", vec1[i]);
		if (i == vec1.size() - 1) printf("\n");
	}
	printf("%d\n", vec2.size());
	for (i = 0; i < vec2.size(); ++i) printf("%d ", vec2[i]);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y))
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
vector<int> vec1, vec2;

int main()
{
	int i, j;
	ll a, b;
	scanf("%lld%lld", &a, &b);
	bool flag = false;
	if (a > b) {
		swap(a, b);
		flag = true;
	}
	ll l = 1ll;
	ll h = (ll)1e9;
	ll tm = -1ll;
	ll ts = -1ll;
	while (l <= h) {
		ll m = (l + h) >> 1;
		ll s = (ll)((double)(1 + m)*(double)m / 2.0);
		if (s <= a) {
			l = m + 1;
			tm = m;
			ts = s;
		}
		else h = m - 1;
	}
	ll need = a - ts;
	for (i = 1; i < tm; ++i) vec1.push_back(i);
	vec1.push_back(tm + need);
	ll sum = 0ll;
	for (i = tm; i; ++i) {
		if (i == tm + need) continue;
		if (sum + i > b) break;
		sum += i;
		vec2.push_back(i);
	}
	if (flag) swap(vec1, vec2);
	printf("%d\n", vec1.size());
	for (i = 0; i < vec1.size(); ++i) printf("%d ", vec1[i]);
	printf("\n%d\n", vec2.size());
	for (i = 0; i < vec2.size(); ++i) printf("%d ", vec2[i]);
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#include <iterator>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<pii> vpii;
const int INF = 1e9 + 7;

int sum(int x)
{
	return x * (x + 1) / 2;
}

int main() {
	int a, b;
	cin >> a >> b;
	vi f, s;
	int c = 1;
	int l = 0, r = 8 * 1e4;
	while (l + 1 < r)
	{
		int m = (l + r) / 2;
		if (sum(m) <= a + b)
			l = m;
		else
			r = m;
	}
	while (l > 0 && ( a >= l || b >= l))
	{
		if (a == l)
			a -= l, f.push_back(l), l--;
		else if (b == l)
			b -= l, s.push_back(l), l--;
		else
		{
			if (a < b && a >= l)
					a -= l, f.push_back(l), l--;
			else if (b >= l)
				b -= l, s.push_back(l), l--;
		}
	}
	cout << f.size() << endl;
	for (int i : f)
		cout << i << " ";
	cout << endl << s.size() << endl;
	for (int j : s)
		cout << j << " ";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#include <iterator>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<pii> vpii;
const int INF = 1e9 + 7;

int main() {
	int a, b;
	cin >> a >> b;
	vi f, s;
	int c = 1;
	while (c <= a || c <= b)
	{
		if (c == a || c == b)
		{
			if (c == a)
				f.push_back(c), a -= c, c++;
			else
				s.push_back(c), b -= c, c++;
		}
		else
		{
			if (a >= b)
			{
				if (b >= c && b - c >= c + 1)
					b -= c, s.push_back(c), c++;
				else if (a >= c)
					a -= c, f.push_back(c), c++;
			}
			else
			{
				if (a >= c && a - c >= c + 1)
					a -= c, f.push_back(c), c++;
				else if (b >= c)
					b -= c, s.push_back(c), c++;
			}
		}
	}
	cout << f.size() << endl;
	for (int i : f)
		cout << i << " ";
	cout << endl << s.size() << endl;
	for (int j : s)
		cout << j << " ";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#include <iterator>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<pii> vpii;
const int INF = 1e9 + 7;

int main() {
	int a, b;
	cin >> a >> b;
	vi f, s;
	int c = 1;
	while (c <= a || c <= b)
	{
		if (c == a || c == b)
		{
			if (c == a)
				f.push_back(c), a -= c, c++;
			else
				s.push_back(c), b -= c, c++;
		}
		else
		{
			if (a >= b)
			{
				if (b - c >= c + 1)
					b -= c, s.push_back(c), c++;
				else if (a >= c)
					a -= c, f.push_back(c), c++;
			}
			else
			{
				if (a - c >= c + 1)
					a -= c, f.push_back(c), c++;
				else if (a >= c)
					b -= c, s.push_back(c), c++;
			}
		}
	}
	cout << f.size() << endl;
	for (int i : f)
		cout << i << " ";
	cout << endl << s.size() << endl;
	for (int j : s)
		cout << j << " ";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#include <iterator>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<pii> vpii;
const int INF = 1e9 + 7;

int sum(int x)
{
	return x * (x + 1) / 2;
}

int main() {
	int a, b;
	cin >> a >> b;
	vi f, s;
	int c = 1;
	int l = 0, r = 8 * 1e4;
	while (l + 1 < r)
	{
		int m = (l + r) / 2;
		if (sum(m) <= a + b)
			l = m;
		else
			r = m;
	}
	while (l > 0)
	{
		if (a == l)
			a -= l, f.push_back(l), l--;
		else if (b == l)
			b -= l, s.push_back(l), l--;
		else
		{
			if (a > b)
				a -= l, f.push_back(l), l--;
			else
				b -= l, s.push_back(l), l--;
		}
	}
	cout << f.size() << endl;
	for (int i : f)
		cout << i << " ";
	cout << endl << s.size() << endl;
	for (int j : s)
		cout << j << " ";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#include <iterator>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<pii> vpii;
const int INF = 1e9 + 7;

int sum(int x)
{
	return x * (x + 1) / 2;
}

int main() {
	int a, b;
	cin >> a >> b;
	vi f, s;
	int c = 1;
	int l = 1, r = 8 * 1e4;
	while (l + 1 < r)
	{
		int m = (l + r) / 2;
		if (sum(m) <= a + b)
			l = m;
		else
			r = m;
	}
	while (l > 0)
	{
		if (a == l)
			a -= l, f.push_back(l), l--;
		else if (b == l)
			b -= l, s.push_back(l), l--;
		else
		{
			if (a > b)
				a -= l, f.push_back(l), l--;
			else
				b -= l, s.push_back(l), l--;
		}
	}
	cout << f.size() << endl;
	for (int i : f)
		cout << i << " ";
	cout << endl << s.size() << endl;
	for (int j : s)
		cout << j << " ";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#include <iterator>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<pii> vpii;
const int INF = 1e9 + 7;

int main() {
	int a, b;
	cin >> a >> b;
	vi f, s;
	int c = 1;
	while (c <= a || c <= b)
	{
		if (c == a || c == b)
		{
			if (c == a)
				f.push_back(c), a -= c, c++;
			else
				s.push_back(c), b -= c, c++;
		}
		else
		{
			if (a < b)
			{
				if (b >= c && b - c >= c + 1)
					b -= c, s.push_back(c), c++;
				else if (a >= c)
					a -= c, f.push_back(c), c++;
			}
			else
			{
				if (a >= c && a - c >= c + 1)
					a -= c, f.push_back(c), c++;
				else if (b >= c)
					b -= c, s.push_back(c), c++;
			}
		}
	}
	cout << f.size() << endl;
	for (int i : f)
		cout << i << " ";
	cout << endl << s.size() << endl;
	for (int j : s)
		cout << j << " ";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#include <iterator>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<pii> vpii;
const int INF = 1e9 + 7;

int sum(int x)
{
	return x * (x + 1) / 2;
}

int main() {
	int a, b;
	cin >> a >> b;
	vi f, s;
	int c = 1;
	int l = 0, r = 8 * 1e4;
	while (l + 1 < r)
	{
		int m = (l + r) / 2;
		if (sum(m) <= a + b)
			l = m;
		else
			r = m;
	}
	while (l > 0 && ( a >= l || b >= l))
	{
		if (a == l)
			a -= l, f.push_back(l), l--;
		else if (b == l)
			b -= l, s.push_back(l), l--;
		else
		{
			if (a > b)
				a -= l, f.push_back(l), l--;
			else
				b -= l, s.push_back(l), l--;
		}
	}
	cout << f.size() << endl;
	for (int i : f)
		cout << i << " ";
	cout << endl << s.size() << endl;
	for (int j : s)
		cout << j << " ";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#include <iterator>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<pii> vpii;
const int INF = 1e9 + 7;

int sum(int x)
{
	return x * (x + 1) / 2;
}

int main() {
	int a, b;
	cin >> a >> b;
	vi f, s;
	int c = 1;
	int l = 0, r = 8 * 1e4;
	while (l + 1 < r)
	{
		int m = (l + r) / 2;
		if (sum(m) <= a + b)
			l = m;
		else
			r = m;
	}
	while (l > 0 && ( a >= l || b >= l))
	{
		if (a == l)
			a -= l, f.push_back(l), l--;
		else if (b == l)
			b -= l, s.push_back(l), l--;
		else
		{
			if (a > b)
			{
				if (a >= l)
					a -= l, f.push_back(l), l--;
			}
			else if (b >= l)
				b -= l, s.push_back(l), l--;
		}
	}
	cout << f.size() << endl;
	for (int i : f)
		cout << i << " ";
	cout << endl << s.size() << endl;
	for (int j : s)
		cout << j << " ";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#include <iterator>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<pii> vpii;
const int INF = 1e9 + 7;

int sum(int x)
{
	return x * (x + 1) / 2;
}

int main() {
	int a, b;
	cin >> a >> b;
	vi f, s;
	int c = 1;
	int l = 0, r = 8 * 1e4;
	while (l + 1 < r)
	{
		int m = (l + r) / 2;
		if (sum(m) <= a + b)
			l = m;
		else
			r = m;
	}
	while (l > 0 || a >= l || b >= l)
	{
		if (a == l)
			a -= l, f.push_back(l), l--;
		else if (b == l)
			b -= l, s.push_back(l), l--;
		else
		{
			if (a > b)
				a -= l, f.push_back(l), l--;
			else
				b -= l, s.push_back(l), l--;
		}
	}
	cout << f.size() << endl;
	for (int i : f)
		cout << i << " ";
	cout << endl << s.size() << endl;
	for (int j : s)
		cout << j << " ";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#include <iterator>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<pii> vpii;
const int INF = 1e9 + 7;

int main() {
	int a, b;
	cin >> a >> b;
	vi f, s;
	int c = 1;
	while (c <= a || c <= b)
	{
		if (c == a || c == b)
		{
			if (c == a)
				f.push_back(c), a -= c, c++;
			else
				s.push_back(c), b -= c, c++;
		}
		else
		{
			if (a < b || a < c)
			{
				if (b >= c && b - c >= c + 1)
					b -= c, s.push_back(c), c++;
				else if (b >= c)
					b -= c, s.push_back(c), c++;
			}
			else
			{
				if (a >= c && a - c >= c + 1)
					a -= c, f.push_back(c), c++;
				else if (a >= c)
					a -= c, f.push_back(c), c++;
			}
		}
	}
	cout << f.size() << endl;
	for (int i : f)
		cout << i << " ";
	cout << endl << s.size() << endl;
	for (int j : s)
		cout << j << " ";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#include <iterator>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<pii> vpii;
const int INF = 1e9 + 7;

ll sum(ll x)
{
	return x * (x + 1) / 2;
}

int main() {
	ll a, b;
	cin >> a >> b;
	vi f, s;
	ll c = 1;
	ll l = 0, r = 1e5;
	while (l + 1 < r)
	{
		ll m = (l + r) / 2;
		if (sum(m) <= a + b)
			l = m;
		else
			r = m;
	}
	while (l > 0 && ( a >= l || b >= l))
	{
		if (a == l)
			a -= l, f.push_back(l), l--;
		else if (b == l)
			b -= l, s.push_back(l), l--;
		else
		{
			if (a > b && a >= l)
					a -= l, f.push_back(l), l--;
			else if (b >= l)
				b -= l, s.push_back(l), l--;
		}
	}
	cout << f.size() << endl;
	for (int i : f)
		cout << i << " ";
	cout << endl << s.size() << endl;
	for (int j : s)
		cout << j << " ";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
#include <iterator>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<pii> vpii;
const int INF = 1e9 + 7;

int sum(int x)
{
	return x * (x + 1) / 2;
}

int main() {
	int a, b;
	cin >> a >> b;
	vi f, s;
	int c = 1;
	int l = 1, r = 4 * 1e4;
	while (l + 1 < r)
	{
		int m = (l + r) / 2;
		if (sum(m) <= a + b)
			l = m;
		else
			r = m;
	}
	while (l > 0)
	{
		if (a == l)
			a -= l, f.push_back(l), l--;
		else if (b == l)
			b -= l, s.push_back(l), l--;
		else
		{
			if (a > b)
				a -= l, f.push_back(l), l--;
			else
				b -= l, s.push_back(l), l--;
		}
	}
	cout << f.size() << endl;
	for (int i : f)
		cout << i << " ";
	cout << endl << s.size() << endl;
	for (int j : s)
		cout << j << " ";
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
	ll a, b, k = 0, z = 0;
	cin >> a >> b;

	while ((k + 1) * (k + 2) / 2 <= a + b)
		k++;

	while ((z + 1) * (z + 2) / 2 <= a)
		z++;

	vector <ll> v1;

	for (ll i = 0; i < z; i++)
		v1.push_back(i + 1);

	for (ll i = 0; i < a - z * (z + 1) / 2; i++)
		v1[z - 1 - i]++;

	vector <ll> v2, vs(k + 1);

	for (ll i = 0; i < v1.size(); i++)
		vs[v1[i]] = 1;

	for (ll i = 1; i <= k; i++)
		if (!vs[i])
			v2.push_back(i);

	cout << v1.size() << endl;

	for (int i = 0; i < v1.size(); i++)
		cout << v1[i] << " ";

	cout << endl << v2.size() << endl;

	for (int i = 0; i < v2.size(); i++)
		cout << v2[i] << " ";

	cout << endl;
}


#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a, b, k = 0, z = 0;
	cin >> a >> b;

	while ((k + 1) * (k + 2) / 2 <= a + b)
		k++;

	while (z * (z + 1) / 2 < a)
		z++;

	if (z * (z + 1) / 2 == a)
	{
		cout << z << endl;

		for (ll i = 1; i <= z; i++)
			cout << i << " ";

		cout << endl << k - z << endl;

		for (ll i = z + 1; i <= k; i++)
			cout << i << " ";

		return 0;
	}

	cout << z - 1 << endl;

	for (ll i = 1; i < z * (z + 1) / 2 - a; i++)
		cout << i << " ";

	for (ll i = z * (z + 1) / 2 - a + 1; i <= z; i++)
		cout << i << " ";

	cout << endl << k - z + 1 << endl;
	cout << z * (z + 1) / 2 - a << " ";

	for (ll i = z + 1; i <= k; i++)
		cout << i << " ";
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
	ll a, b, k = 0, z = 0;
	cin >> a >> b;

	while ((k + 1) * (k + 2) / 2 <= a + b)
		k++;

	while ((z + 1) * (z + 2) / 2 <= a)
		z++;

	vector <ll> v1;

	for (ll i = 0; i < z; i++)
		v1.push_back(i + 1);

	for (ll i = 0; i < a - z * (z + 1) / 2; i++)
		v1[z - 1 - i]++;

	vector <ll> v2, vs(k + 1);

	for (ll i = 0; i < v1.size(); i++)
		vs[v1[i]] = 1;

	for (ll i = 1; i <= k; i++)
		if (!vs[i])
			v2.push_back(i);

	cout << v1.size() << endl;

	for (int i = 0; i < v1.size(); i++)
		cout << v1[i] << " ";

	cout << endl << v2.size() << endl;

	for (int i = 0; i < v2.size(); i++)
		cout << v2[i] << " ";

	cout << "";
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
	ll a, b, k = 0, z = 0;
	cin >> a >> b;

	while ((k + 1) * (k + 2) / 2 <= a + b)
		k++;

	while ((z + 1) * (z + 2) / 2 <= a)
		z++;

	vector <ll> v1;

	for (ll i = 0; i < z; i++)
		v1.push_back(i + 1);

	for (ll i = 0; i < a - z * (z + 1) / 2; i++)
		v1[z - 1 - i]++;

	ll ptr1 = 0;
	vector <ll> v2, vs(k + 1);

	for (ll i = 0; i < v1.size(); i++)
		vs[v1[i]] = 1;

	for (ll i = 1; i <= k; i++)
		if (!vs[i])
			v2.push_back(i);

	cout << v1.size() << endl;

	for (int i = 0; i < v1.size(); i++)
		cout << v1[i] << " ";

	cout << endl << v2.size() << endl;

	for (int i = 0; i < v2.size(); i++)
		cout << v2[i] << " ";
}


#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a, b, k = 0, z = 0;
	cin >> a >> b;

	while ((k + 1) * (k + 2) / 2 <= a + b)
		k++;

	while (z * (z + 1) / 2 < a)
		z++;

	if (z * (z + 1) / 2 == a)
	{
		cout << z << endl;

		for (ll i = 1; i <= z; i++)
			cout << i << " ";

		cout << endl << k - z << endl;

		for (ll i = z + 1; i <= k; i++)
			cout << i << " ";

		return 0;
	}

	if (z > k)
	{
		cout << k << endl;

		for (ll i = 1; i <= k; i++)
			cout << i << " ";

		cout << "\n0\n";
		return 0;
	}

	cout << z - 1 << endl;

	for (ll i = 1; i < z * (z + 1) / 2 - a; i++)
		cout << i << " ";

	for (ll i = z * (z + 1) / 2 - a + 1; i <= z; i++)
		cout << i << " ";

	cout << endl << k - z + 1 << endl;
	cout << z * (z + 1) / 2 - a << " ";

	for (ll i = z + 1; i <= k; i++)
		cout << i << " ";
}


#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mem(a, b) memset(a, (b), sizeof(a))
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define mod1 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define inf LLONG_MAX
#define endl "\n"
#define F first
#define S second
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);for(int i = 0; i<n; i++)cin>>a[i];
const double pi=acos(-1.0);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; //greater<int> can also be used
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sz(c) (int)c.size()
#define d1(x)            cout<<#x<<"="<<x<<endl;
#define d2(x,y)          cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define d3(x,y,z)        cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define d4(x,y,z,w)      cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w <<"="<<w<<endl;
#define da(arr,j,n)  for(int i=j;i<n;i++) {cout<<"i="<<i<<" arr[i]="<<arr[i]<<"\n";}

const  ll MODA =                         1000000007;
// const  int MODA =                     998244353 ;
vector<ll> primefactors    ;            // used by generatePrimeFactors()                                                                                // ARRAYS/VECTORS
vector<ll> factors         ;            // used by generateFactors()
ll   fact[100005]={}         ;            // used by generateFactorial() & ncr()
bool isPowerTwo(ll x)                   { return (x && !(x & (x - 1))); }                                                                                // FUNCTIONS
ll   modmul(ll a,ll b)                  { return((a%MODA)*(b%MODA))%MODA;     }
ll   modadd(ll a,ll b)                  { return((a%MODA)+(b%MODA)+MODA)%MODA;}
ll   modsub(ll a,ll b)                  { return((a%MODA)-(b%MODA)+MODA)%MODA;}
bool isSubstring(string s1, string s2)  { if (s1.find(s2) != string::npos) return true; else return false; }
void generateFactorial(ll n)            { fact[0] = 1; for(ll i = 1; i <= n; i++)   fact[i] = (i* 1ll * fact[i - 1]) ; }
void generateFactorialMOD(ll n)         { fact[0] = 1; for(ll i = 1; i <= n; i++)   fact[i] = (i* 1ll * fact[i - 1]) % MODA; }
bool isPrime(ll n)                      { if(n<2) return false; for(ll i=2;i*i<=n;i++) if(n%i==0) return false; return true; } //O(sqrt(n))
ll   power(ll a, ll b)                  {   ll res=1; while(b) {    if(b&1) res=(res*a); a=(a*a);   b>>=1;  }   return res; }
ll   powermod(ll a, ll b)               {   ll res=1; while(b) {    if(b&1) res=(res*a)%MODA; a=(a*a)%MODA;     b>>=1;  }   return res; }
ll   modi (ll a)                        { ll m=MODA,s=1,p=0;  while(a>1)  {  ll q=a/m,t=m;  m=a%m; a=t; t=p; p=s-q*p; s=t;  } return s>=0 ? s :s+MODA; }
void generatePrimeFactors(ll n)         { primefactors.clear(); for(ll i=2;i*i<=n;i++) { if(n%i==0) { primefactors.pb(i); while(n%i==0)  n=n/i; } } if(n!=1)   primefactors.pb(n); }
ll   ncr(ll n, ll r)                    { if(r==0)return 1;  fact[0]=1; for(int i=1 ; i<=n; i++) fact[i] = fact[i-1]*i%MODA;   return (fact[n]* modi(fact[r]) % MODA *  modi(fact[n-r]) % MODA) % MODA; }
void generateFactors(ll n)              { factors.clear(); for(ll i=2;i*i<=n;i++){ if(n%i==0) { factors.pb(i); if(n/i!=i)factors.pb(n/i); }} factors.pb(1); factors.pb(n); sort(factors.begin(),factors.end()); }
ld   Logn(ld n, ld r)                   { return log(n) / log(r); }

///////////////////////////////////
const int Nmax = 1000005;

////////////////////////////////////

void solve(){

   ll d1, d2;

   cin >> d1 >> d2;

   set<int> used1;

   for(int i = 1; ; i++){

        if(i == d1){
            used1.insert(i);
            d1 -= i;
            break;
        }
        else if(d1 <= 2*i){
            used1.insert(d1);
            d1 = 0;
            break;
        }
        else{
            used1.insert(i);
            d1 -= i;
        }

   }
   set<int> used2;
   for(int i = 1; ; i++){
    if(d2 < i){
        break;
    }
    if(used1.find(i) == used1.end()){

        if(i <= d2){
            used2.insert(i);
            d2 -= i;
        }

    }
   }

   cout << sz(used1) << endl;
   auto it = used1.begin();

   while(it != used1.end()){
    cout << *it << " ";
    it++;
   }
   cout << endl;
   it = used2.begin();

   cout << sz(used2) << endl;
   while(it != used2.end()){
    cout << *it << " ";
    it++;
   }
   cout << endl;

}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
      ios_base::sync_with_stdio(false); cin.tie(0);

      int t= 1;
       // cin >> t;

        while(t--){
            solve();
        }

        printclock;

  }

/////////////////////////////
//try to bring as much symmetry as possible
//just check for integer overflow
//add MOD value when you substract two numbers
//clear globally declared vectors after each test case
// don't return or break while taking input of particular test case
/////////////////////////////


#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mem(a, b) memset(a, (b), sizeof(a))
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define mod1 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define inf LLONG_MAX
#define endl "\n"
#define F first
#define S second
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);for(int i = 0; i<n; i++)cin>>a[i];
const double pi=acos(-1.0);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; //greater<int> can also be used
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sz(c) (int)c.size()
#define d1(x)            cout<<#x<<"="<<x<<endl;
#define d2(x,y)          cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define d3(x,y,z)        cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define d4(x,y,z,w)      cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w <<"="<<w<<endl;
#define da(arr,j,n)  for(int i=j;i<n;i++) {cout<<"i="<<i<<" arr[i]="<<arr[i]<<"\n";}

const  ll MODA =                         1000000007;
// const  int MODA =                     998244353 ;
vector<ll> primefactors    ;            // used by generatePrimeFactors()                                                                                // ARRAYS/VECTORS
vector<ll> factors         ;            // used by generateFactors()
ll   fact[100005]={}         ;            // used by generateFactorial() & ncr()
bool isPowerTwo(ll x)                   { return (x && !(x & (x - 1))); }                                                                                // FUNCTIONS
ll   modmul(ll a,ll b)                  { return((a%MODA)*(b%MODA))%MODA;     }
ll   modadd(ll a,ll b)                  { return((a%MODA)+(b%MODA)+MODA)%MODA;}
ll   modsub(ll a,ll b)                  { return((a%MODA)-(b%MODA)+MODA)%MODA;}
bool isSubstring(string s1, string s2)  { if (s1.find(s2) != string::npos) return true; else return false; }
void generateFactorial(ll n)            { fact[0] = 1; for(ll i = 1; i <= n; i++)   fact[i] = (i* 1ll * fact[i - 1]) ; }
void generateFactorialMOD(ll n)         { fact[0] = 1; for(ll i = 1; i <= n; i++)   fact[i] = (i* 1ll * fact[i - 1]) % MODA; }
bool isPrime(ll n)                      { if(n<2) return false; for(ll i=2;i*i<=n;i++) if(n%i==0) return false; return true; } //O(sqrt(n))
ll   power(ll a, ll b)                  {   ll res=1; while(b) {    if(b&1) res=(res*a); a=(a*a);   b>>=1;  }   return res; }
ll   powermod(ll a, ll b)               {   ll res=1; while(b) {    if(b&1) res=(res*a)%MODA; a=(a*a)%MODA;     b>>=1;  }   return res; }
ll   modi (ll a)                        { ll m=MODA,s=1,p=0;  while(a>1)  {  ll q=a/m,t=m;  m=a%m; a=t; t=p; p=s-q*p; s=t;  } return s>=0 ? s :s+MODA; }
void generatePrimeFactors(ll n)         { primefactors.clear(); for(ll i=2;i*i<=n;i++) { if(n%i==0) { primefactors.pb(i); while(n%i==0)  n=n/i; } } if(n!=1)   primefactors.pb(n); }
ll   ncr(ll n, ll r)                    { if(r==0)return 1;  fact[0]=1; for(int i=1 ; i<=n; i++) fact[i] = fact[i-1]*i%MODA;   return (fact[n]* modi(fact[r]) % MODA *  modi(fact[n-r]) % MODA) % MODA; }
void generateFactors(ll n)              { factors.clear(); for(ll i=2;i*i<=n;i++){ if(n%i==0) { factors.pb(i); if(n/i!=i)factors.pb(n/i); }} factors.pb(1); factors.pb(n); sort(factors.begin(),factors.end()); }
ld   Logn(ld n, ld r)                   { return log(n) / log(r); }

///////////////////////////////////
const int Nmax = 1000005;

////////////////////////////////////

void solve(){

   ll d1, d2;

   cin >> d1 >> d2;

   set<int> used1;

   for(int i = 1; ; i++){

        if(i > d1){
            break;
        }

        if(i == d1){
            used1.insert(i);
            d1 -= i;
            break;
        }
        else if(d1 <= 2*i){
            used1.insert(d1);
            d1 = 0;
            break;
        }
        else{
            used1.insert(i);
            d1 -= i;
        }

   }
   set<int> used2;
   for(int i = 1; ; i++){
    if(d2 < i){
        break;
    }
    if(used1.find(i) == used1.end()){

        if(i <= d2){
            used2.insert(i);
            d2 -= i;
        }

    }
   }

   cout << sz(used1) << endl;
   auto it = used1.begin();

   while(it != used1.end()){
    cout << *it << " ";
    it++;
   }
   cout << endl;
   it = used2.begin();

   cout << sz(used2) << endl;
   while(it != used2.end()){
    cout << *it << " ";
    it++;
   }
   cout << endl;

}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
      ios_base::sync_with_stdio(false); cin.tie(0);

      int t= 1;
       // cin >> t;

        while(t--){
            solve();
        }

        printclock;

  }

/////////////////////////////
//try to bring as much symmetry as possible
//just check for integer overflow
//add MOD value when you substract two numbers
//clear globally declared vectors after each test case
// don't return or break while taking input of particular test case
/////////////////////////////


#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mem(a, b) memset(a, (b), sizeof(a))
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define mod1 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define inf LLONG_MAX
#define endl "\n"
#define F first
#define S second
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);for(int i = 0; i<n; i++)cin>>a[i];
const double pi=acos(-1.0);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; //greater<int> can also be used
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sz(c) (int)c.size()
#define d1(x)            cout<<#x<<"="<<x<<endl;
#define d2(x,y)          cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define d3(x,y,z)        cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define d4(x,y,z,w)      cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w <<"="<<w<<endl;
#define da(arr,j,n)  for(int i=j;i<n;i++) {cout<<"i="<<i<<" arr[i]="<<arr[i]<<"\n";}

const  ll MODA =                         1000000007;
// const  int MODA =                     998244353 ;
vector<ll> primefactors    ;            // used by generatePrimeFactors()                                                                                // ARRAYS/VECTORS
vector<ll> factors         ;            // used by generateFactors()
ll   fact[100005]={}         ;            // used by generateFactorial() & ncr()
bool isPowerTwo(ll x)                   { return (x && !(x & (x - 1))); }                                                                                // FUNCTIONS
ll   modmul(ll a,ll b)                  { return((a%MODA)*(b%MODA))%MODA;     }
ll   modadd(ll a,ll b)                  { return((a%MODA)+(b%MODA)+MODA)%MODA;}
ll   modsub(ll a,ll b)                  { return((a%MODA)-(b%MODA)+MODA)%MODA;}
bool isSubstring(string s1, string s2)  { if (s1.find(s2) != string::npos) return true; else return false; }
void generateFactorial(ll n)            { fact[0] = 1; for(ll i = 1; i <= n; i++)   fact[i] = (i* 1ll * fact[i - 1]) ; }
void generateFactorialMOD(ll n)         { fact[0] = 1; for(ll i = 1; i <= n; i++)   fact[i] = (i* 1ll * fact[i - 1]) % MODA; }
bool isPrime(ll n)                      { if(n<2) return false; for(ll i=2;i*i<=n;i++) if(n%i==0) return false; return true; } //O(sqrt(n))
ll   power(ll a, ll b)                  {   ll res=1; while(b) {    if(b&1) res=(res*a); a=(a*a);   b>>=1;  }   return res; }
ll   powermod(ll a, ll b)               {   ll res=1; while(b) {    if(b&1) res=(res*a)%MODA; a=(a*a)%MODA;     b>>=1;  }   return res; }
ll   modi (ll a)                        { ll m=MODA,s=1,p=0;  while(a>1)  {  ll q=a/m,t=m;  m=a%m; a=t; t=p; p=s-q*p; s=t;  } return s>=0 ? s :s+MODA; }
void generatePrimeFactors(ll n)         { primefactors.clear(); for(ll i=2;i*i<=n;i++) { if(n%i==0) { primefactors.pb(i); while(n%i==0)  n=n/i; } } if(n!=1)   primefactors.pb(n); }
ll   ncr(ll n, ll r)                    { if(r==0)return 1;  fact[0]=1; for(int i=1 ; i<=n; i++) fact[i] = fact[i-1]*i%MODA;   return (fact[n]* modi(fact[r]) % MODA *  modi(fact[n-r]) % MODA) % MODA; }
void generateFactors(ll n)              { factors.clear(); for(ll i=2;i*i<=n;i++){ if(n%i==0) { factors.pb(i); if(n/i!=i)factors.pb(n/i); }} factors.pb(1); factors.pb(n); sort(factors.begin(),factors.end()); }
ld   Logn(ld n, ld r)                   { return log(n) / log(r); }

///////////////////////////////////
const int Nmax = 1000005;

////////////////////////////////////

void solve(){

   ll d1, d2;

   cin >> d1 >> d2;
    int swp = 0;
    if(d1 > d2 ){
        swp = 1;
        swap(d1, d2);
    }

    ll x = (sqrt(1 + 8*(d1+d2)) - 1)/2;

    vector<int> v;
    for(int i = 0; i<=x; i++){
        v.pb(x);
    }
    vector<int> v1, v2;

    if(d1 <= x){
        v1.pb(d1);

        cout << x - 1 << endl;
        for(int i = 1; i<= x; i++){
            if(i!= d1){
                v2.pb(d2);
            }

        }
    }
    else{
        int sv = -1;
        int ep = x;

        int sum = x;

        v1.pb(x);
        while(sum < d1){
            ep--;
            sum+=ep;

            if(sum > d1){
                sum-=ep;
                ep++;
                sv = d1 - sum;
                v1.pb(sv);
                break;
            }
            else if(sum == d1){
                v1.pb(ep);
                break;
            }
            else{
                v1.pb(ep);
            }

        }

        for(int i = 1; i< ep; i++){
            if(i!= sv){
                v2.pb(i);
            }
        }

    }

    if(swp){
        cout << sz(v2) << endl;
        for(int i = 0; i< sz(v2); i++){
            cout << v2[i] << " ";
        }
        cout << endl;

        cout << sz(v1) << endl;
        for(int i = 0; i< sz(v1); i++){
            cout << v1[i] << " ";
        }
        cout << endl;
    }
    else{

        cout << sz(v1) << endl;
        for(int i = 0; i< sz(v1); i++){
            cout << v1[i] << " ";
        }
        cout << endl;

         cout << sz(v2) << endl;
        for(int i = 0; i< sz(v2); i++){
            cout << v2[i] << " ";
        }
        cout << endl;

    }

}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
      ios_base::sync_with_stdio(false); cin.tie(0);

      int t= 1;
       // cin >> t;

        while(t--){
            solve();
        }

        printclock;

  }

/////////////////////////////
//try to bring as much symmetry as possible
//just check for integer overflow
//add MOD value when you substract two numbers
//clear globally declared vectors after each test case
// don't return or break while taking input of particular test case
/////////////////////////////


#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mem(a, b) memset(a, (b), sizeof(a))
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define mod1 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define inf LLONG_MAX
#define endl "\n"
#define F first
#define S second
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);for(int i = 0; i<n; i++)cin>>a[i];
const double pi=acos(-1.0);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; //greater<int> can also be used
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sz(c) (int)c.size()
#define d1(x)            cout<<#x<<"="<<x<<endl;
#define d2(x,y)          cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define d3(x,y,z)        cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define d4(x,y,z,w)      cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w <<"="<<w<<endl;
#define da(arr,j,n)  for(int i=j;i<n;i++) {cout<<"i="<<i<<" arr[i]="<<arr[i]<<"\n";}

const  ll MODA =                         1000000007;
// const  int MODA =                     998244353 ;
vector<ll> primefactors    ;            // used by generatePrimeFactors()                                                                                // ARRAYS/VECTORS
vector<ll> factors         ;            // used by generateFactors()
ll   fact[100005]={}         ;            // used by generateFactorial() & ncr()
bool isPowerTwo(ll x)                   { return (x && !(x & (x - 1))); }                                                                                // FUNCTIONS
ll   modmul(ll a,ll b)                  { return((a%MODA)*(b%MODA))%MODA;     }
ll   modadd(ll a,ll b)                  { return((a%MODA)+(b%MODA)+MODA)%MODA;}
ll   modsub(ll a,ll b)                  { return((a%MODA)-(b%MODA)+MODA)%MODA;}
bool isSubstring(string s1, string s2)  { if (s1.find(s2) != string::npos) return true; else return false; }
void generateFactorial(ll n)            { fact[0] = 1; for(ll i = 1; i <= n; i++)   fact[i] = (i* 1ll * fact[i - 1]) ; }
void generateFactorialMOD(ll n)         { fact[0] = 1; for(ll i = 1; i <= n; i++)   fact[i] = (i* 1ll * fact[i - 1]) % MODA; }
bool isPrime(ll n)                      { if(n<2) return false; for(ll i=2;i*i<=n;i++) if(n%i==0) return false; return true; } //O(sqrt(n))
ll   power(ll a, ll b)                  {   ll res=1; while(b) {    if(b&1) res=(res*a); a=(a*a);   b>>=1;  }   return res; }
ll   powermod(ll a, ll b)               {   ll res=1; while(b) {    if(b&1) res=(res*a)%MODA; a=(a*a)%MODA;     b>>=1;  }   return res; }
ll   modi (ll a)                        { ll m=MODA,s=1,p=0;  while(a>1)  {  ll q=a/m,t=m;  m=a%m; a=t; t=p; p=s-q*p; s=t;  } return s>=0 ? s :s+MODA; }
void generatePrimeFactors(ll n)         { primefactors.clear(); for(ll i=2;i*i<=n;i++) { if(n%i==0) { primefactors.pb(i); while(n%i==0)  n=n/i; } } if(n!=1)   primefactors.pb(n); }
ll   ncr(ll n, ll r)                    { if(r==0)return 1;  fact[0]=1; for(int i=1 ; i<=n; i++) fact[i] = fact[i-1]*i%MODA;   return (fact[n]* modi(fact[r]) % MODA *  modi(fact[n-r]) % MODA) % MODA; }
void generateFactors(ll n)              { factors.clear(); for(ll i=2;i*i<=n;i++){ if(n%i==0) { factors.pb(i); if(n/i!=i)factors.pb(n/i); }} factors.pb(1); factors.pb(n); sort(factors.begin(),factors.end()); }
ld   Logn(ld n, ld r)                   { return log(n) / log(r); }

///////////////////////////////////
const int Nmax = 1000005;

////////////////////////////////////

void solve(){

   ll d1, d2;

   cin >> d1 >> d2;
    int swp = 0;
    if(d1 > d2 ){
        swp = 1;
        swap(d1, d2);
    }

    ll x = (sqrt(1 + 8*(d1+d2)) - 1)/2;

    vector<int> v;
    for(int i = 0; i<=x; i++){
        v.pb(x);
    }
    vector<int> v1, v2;

    if(d1 <= x){
        if(d1 != 0){
             v1.pb(d1);

        }

         for(int i = 1; i<= x; i++){
            if(i!= d1){
                v2.pb(i);
            }

        }

    }
    else{
        int sv = -1;
        int ep = x;

        int sum = x;

        v1.pb(x);

        while(sum < d1){
            ep--;
            sum+=ep;

            if(sum > d1){

                sum-=ep;
                ep++;
                sv = d1 - sum;
                v1.pb(sv);
                break;
            }
            else if(sum == d1){
                v1.pb(ep);
                break;
            }
            else{
                v1.pb(ep);
            }

        }

        for(int i = 1; i< ep; i++){
            if(i!= sv){
                v2.pb(i);
            }
        }

    }

    if(swp){
        cout << sz(v2) << endl;
        for(int i = 0; i< sz(v2); i++){
            cout << v2[i] << " ";
        }
        cout << endl;

        cout << sz(v1) << endl;
        for(int i = 0; i< sz(v1); i++){
            cout << v1[i] << " ";
        }
        cout << endl;
    }
    else{

        cout << sz(v1) << endl;
        for(int i = 0; i< sz(v1); i++){
            cout << v1[i] << " ";
        }
        cout << endl;

         cout << sz(v2) << endl;
        for(int i = 0; i< sz(v2); i++){
            cout << v2[i] << " ";
        }
        cout << endl;

    }

}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
      ios_base::sync_with_stdio(false); cin.tie(0);

      int t= 1;
       // cin >> t;

        while(t--){
            solve();
        }

        printclock;

  }

/////////////////////////////
//try to bring as much symmetry as possible
//just check for integer overflow
//add MOD value when you substract two numbers
//clear globally declared vectors after each test case
// don't return or break while taking input of particular test case
/////////////////////////////


#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mem(a, b) memset(a, (b), sizeof(a))
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define mod1 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define inf LLONG_MAX
#define endl "\n"
#define F first
#define S second
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);for(int i = 0; i<n; i++)cin>>a[i];
const double pi=acos(-1.0);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; //greater<int> can also be used
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sz(c) (int)c.size()
#define d1(x)            cout<<#x<<"="<<x<<endl;
#define d2(x,y)          cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define d3(x,y,z)        cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define d4(x,y,z,w)      cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w <<"="<<w<<endl;
#define da(arr,j,n)  for(int i=j;i<n;i++) {cout<<"i="<<i<<" arr[i]="<<arr[i]<<"\n";}

const  ll MODA =                         1000000007;
// const  int MODA =                     998244353 ;
vector<ll> primefactors    ;            // used by generatePrimeFactors()                                                                                // ARRAYS/VECTORS
vector<ll> factors         ;            // used by generateFactors()
ll   fact[100005]={}         ;            // used by generateFactorial() & ncr()
bool isPowerTwo(ll x)                   { return (x && !(x & (x - 1))); }                                                                                // FUNCTIONS
ll   modmul(ll a,ll b)                  { return((a%MODA)*(b%MODA))%MODA;     }
ll   modadd(ll a,ll b)                  { return((a%MODA)+(b%MODA)+MODA)%MODA;}
ll   modsub(ll a,ll b)                  { return((a%MODA)-(b%MODA)+MODA)%MODA;}
bool isSubstring(string s1, string s2)  { if (s1.find(s2) != string::npos) return true; else return false; }
void generateFactorial(ll n)            { fact[0] = 1; for(ll i = 1; i <= n; i++)   fact[i] = (i* 1ll * fact[i - 1]) ; }
void generateFactorialMOD(ll n)         { fact[0] = 1; for(ll i = 1; i <= n; i++)   fact[i] = (i* 1ll * fact[i - 1]) % MODA; }
bool isPrime(ll n)                      { if(n<2) return false; for(ll i=2;i*i<=n;i++) if(n%i==0) return false; return true; } //O(sqrt(n))
ll   power(ll a, ll b)                  {   ll res=1; while(b) {    if(b&1) res=(res*a); a=(a*a);   b>>=1;  }   return res; }
ll   powermod(ll a, ll b)               {   ll res=1; while(b) {    if(b&1) res=(res*a)%MODA; a=(a*a)%MODA;     b>>=1;  }   return res; }
ll   modi (ll a)                        { ll m=MODA,s=1,p=0;  while(a>1)  {  ll q=a/m,t=m;  m=a%m; a=t; t=p; p=s-q*p; s=t;  } return s>=0 ? s :s+MODA; }
void generatePrimeFactors(ll n)         { primefactors.clear(); for(ll i=2;i*i<=n;i++) { if(n%i==0) { primefactors.pb(i); while(n%i==0)  n=n/i; } } if(n!=1)   primefactors.pb(n); }
ll   ncr(ll n, ll r)                    { if(r==0)return 1;  fact[0]=1; for(int i=1 ; i<=n; i++) fact[i] = fact[i-1]*i%MODA;   return (fact[n]* modi(fact[r]) % MODA *  modi(fact[n-r]) % MODA) % MODA; }
void generateFactors(ll n)              { factors.clear(); for(ll i=2;i*i<=n;i++){ if(n%i==0) { factors.pb(i); if(n/i!=i)factors.pb(n/i); }} factors.pb(1); factors.pb(n); sort(factors.begin(),factors.end()); }
ld   Logn(ld n, ld r)                   { return log(n) / log(r); }

///////////////////////////////////
const int Nmax = 1000005;

////////////////////////////////////

void solve(){

   ll d1, d2;

   cin >> d1 >> d2;
   int isw = 0;
   if(d1 > d2){
    isw = 1;
    swap(d1, d2);
   }

   set<int> used1;

   for(int i = 1; ; i++){

        if(i > d1){
            break;
        }

        if(i == d1){
            used1.insert(i);
            d1 -= i;
            break;
        }
        else if(d1 <= 2*i){
            used1.insert(d1);
            d1 = 0;
            break;
        }
        else{
            used1.insert(i);
            d1 -= i;
        }

   }
   set<int> used2;
   for(int i = 1; ; i++){
    if(d2 < i){
        break;
    }
    if(used1.find(i) == used1.end()){

        if(i <= d2){
            used2.insert(i);
            d2 -= i;
        }

    }
   }

   if(isw){

   auto it = used2.begin();

   cout << sz(used2) << endl;
   while(it != used2.end()){
    cout << *it << " ";
    it++;
   }
   cout << endl;

   cout << sz(used1) << endl;
   it = used1.begin();

   while(it != used1.end()){
    cout << *it << " ";
    it++;
   }
   cout << endl;

}

    else{
        cout << sz(used1) << endl;
   auto it = used1.begin();

   while(it != used1.end()){
    cout << *it << " ";
    it++;
   }
   cout << endl;
   it = used2.begin();

   cout << sz(used2) << endl;
   while(it != used2.end()){
    cout << *it << " ";
    it++;
   }
   cout << endl;
    }

}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
      ios_base::sync_with_stdio(false); cin.tie(0);

      int t= 1;
       // cin >> t;

        while(t--){
            solve();
        }

        printclock;

  }

/////////////////////////////
//try to bring as much symmetry as possible
//just check for integer overflow
//add MOD value when you substract two numbers
//clear globally declared vectors after each test case
// don't return or break while taking input of particular test case
/////////////////////////////


#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mem(a, b) memset(a, (b), sizeof(a))
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define mod1 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define inf LLONG_MAX
#define endl "\n"
#define F first
#define S second
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);for(int i = 0; i<n; i++)cin>>a[i];
const double pi=acos(-1.0);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; //greater<int> can also be used
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sz(c) (int)c.size()
#define d1(x)            cout<<#x<<"="<<x<<endl;
#define d2(x,y)          cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define d3(x,y,z)        cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define d4(x,y,z,w)      cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w <<"="<<w<<endl;
#define da(arr,j,n)  for(int i=j;i<n;i++) {cout<<"i="<<i<<" arr[i]="<<arr[i]<<"\n";}

const  ll MODA =                         1000000007;
// const  int MODA =                     998244353 ;
vector<ll> primefactors    ;            // used by generatePrimeFactors()                                                                                // ARRAYS/VECTORS
vector<ll> factors         ;            // used by generateFactors()
ll   fact[100005]={}         ;            // used by generateFactorial() & ncr()
bool isPowerTwo(ll x)                   { return (x && !(x & (x - 1))); }                                                                                // FUNCTIONS
ll   modmul(ll a,ll b)                  { return((a%MODA)*(b%MODA))%MODA;     }
ll   modadd(ll a,ll b)                  { return((a%MODA)+(b%MODA)+MODA)%MODA;}
ll   modsub(ll a,ll b)                  { return((a%MODA)-(b%MODA)+MODA)%MODA;}
bool isSubstring(string s1, string s2)  { if (s1.find(s2) != string::npos) return true; else return false; }
void generateFactorial(ll n)            { fact[0] = 1; for(ll i = 1; i <= n; i++)   fact[i] = (i* 1ll * fact[i - 1]) ; }
void generateFactorialMOD(ll n)         { fact[0] = 1; for(ll i = 1; i <= n; i++)   fact[i] = (i* 1ll * fact[i - 1]) % MODA; }
bool isPrime(ll n)                      { if(n<2) return false; for(ll i=2;i*i<=n;i++) if(n%i==0) return false; return true; } //O(sqrt(n))
ll   power(ll a, ll b)                  {   ll res=1; while(b) {    if(b&1) res=(res*a); a=(a*a);   b>>=1;  }   return res; }
ll   powermod(ll a, ll b)               {   ll res=1; while(b) {    if(b&1) res=(res*a)%MODA; a=(a*a)%MODA;     b>>=1;  }   return res; }
ll   modi (ll a)                        { ll m=MODA,s=1,p=0;  while(a>1)  {  ll q=a/m,t=m;  m=a%m; a=t; t=p; p=s-q*p; s=t;  } return s>=0 ? s :s+MODA; }
void generatePrimeFactors(ll n)         { primefactors.clear(); for(ll i=2;i*i<=n;i++) { if(n%i==0) { primefactors.pb(i); while(n%i==0)  n=n/i; } } if(n!=1)   primefactors.pb(n); }
ll   ncr(ll n, ll r)                    { if(r==0)return 1;  fact[0]=1; for(int i=1 ; i<=n; i++) fact[i] = fact[i-1]*i%MODA;   return (fact[n]* modi(fact[r]) % MODA *  modi(fact[n-r]) % MODA) % MODA; }
void generateFactors(ll n)              { factors.clear(); for(ll i=2;i*i<=n;i++){ if(n%i==0) { factors.pb(i); if(n/i!=i)factors.pb(n/i); }} factors.pb(1); factors.pb(n); sort(factors.begin(),factors.end()); }
ld   Logn(ld n, ld r)                   { return log(n) / log(r); }

///////////////////////////////////
const int Nmax = 1000005;

////////////////////////////////////

void solve(){

   ll d1, d2;

   cin >> d1 >> d2;
    int swp = 0;
    if(d1 > d2 ){
        swp = 1;
        swap(d1, d2);
    }

    ll x = (sqrt(1 + 8*(d1+d2)) - 1)/2;

    vector<int> v;
    for(int i = 0; i<=x; i++){
        v.pb(x);
    }
    vector<int> v1, v2;

    if(d1 <= x){
        v1.pb(d1);

        for(int i = 1; i<= x; i++){
            if(i!= d1){
                v2.pb(i);
            }

        }
    }
    else{
        int sv = -1;
        int ep = x;

        int sum = x;

        v1.pb(x);

        while(sum < d1){
            ep--;
            sum+=ep;

            if(sum > d1){

                sum-=ep;
                ep++;
                sv = d1 - sum;
                v1.pb(sv);
                break;
            }
            else if(sum == d1){
                v1.pb(ep);
                break;
            }
            else{
                v1.pb(ep);
            }

        }

        for(int i = 1; i< ep; i++){
            if(i!= sv){
                v2.pb(i);
            }
        }

    }

    if(swp){
        cout << sz(v2) << endl;
        for(int i = 0; i< sz(v2); i++){
            cout << v2[i] << " ";
        }
        cout << endl;

        cout << sz(v1) << endl;
        for(int i = 0; i< sz(v1); i++){
            cout << v1[i] << " ";
        }
        cout << endl;
    }
    else{

        cout << sz(v1) << endl;
        for(int i = 0; i< sz(v1); i++){
            cout << v1[i] << " ";
        }
        cout << endl;

         cout << sz(v2) << endl;
        for(int i = 0; i< sz(v2); i++){
            cout << v2[i] << " ";
        }
        cout << endl;

    }

}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
      ios_base::sync_with_stdio(false); cin.tie(0);

      int t= 1;
       // cin >> t;

        while(t--){
            solve();
        }

        printclock;

  }

/////////////////////////////
//try to bring as much symmetry as possible
//just check for integer overflow
//add MOD value when you substract two numbers
//clear globally declared vectors after each test case
// don't return or break while taking input of particular test case
/////////////////////////////