#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
#define f first
#define s second
multimap<int, int> comps;
pair<int, int> sock[N];
//#define nxt(x) (((~(decltype(x))0) << 1 & x) << 1)
//#define nxt(x) ((x | 1) << 1)
#define nxt(x) ((x + 1) >> 1)
int a[N], b[N], c, u;
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1, x; i <= n; i++)
		scanf("%d", &x), comps.insert(make_pair(x, i));
	for (int i = 1; i <= m; i++)
		scanf("%d", &sock[i].f), sock[i].s = i;
	sort(sock + 1, sock + m + 1);
	for (int i = 1; i <= m && comps.size(); i++)
	{
		int x = sock[i].f;
		int y = comps.begin()->first;
		for (int cnt = 0; x >= y; x = nxt(x), cnt++)
		{
			auto ite = comps.find(x);
			if (ite != comps.end())
			{
				a[sock[i].s] = cnt;
				b[ite->second] = sock[i].s;
				c++, u += cnt;
				comps.erase(ite);
				break;
			}
		}
	}
	printf("%d %d\n", c, u);
	for (int i = 1; i <= m; i++)
		printf("%d ", a[i]);
	putchar('\n');
	for (int i = 1; i <= n; i++)
		printf("%d ", b[i]);
	return 0;
}