#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long
using namespace std; const int N = 2e5 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-;
const double PI = acos(-); int T, m, n, up, dp2[<<], dp[<<], pre[<<];
char s[];
vector<int> ans; int main() {
// freopen("tests.in", "r", stdin);
scanf("%d", &T);
while(T--) {
ans.clear();
scanf("%d%d", &m, &n);
up = << m;
for(int i = ; i < up; i++) dp2[i] = , dp[i] = inf;
for(int i = ; i < n; i++) {
scanf("%s", s); int x = ;
for(int j = ; j < m; j++)
if(s[j] == '') x += << j;
dp2[x]++;
}
for(int i = ; i < m; i++)
for(int s = ; s < up; s++)
if(s>>i&) dp2[s^(<<i)] += dp2[s];
dp[] = ;
for(int s = ; s < up; s++) {
for(int i = ; i < m; i++) {
if(s>>i&) continue;
int nexs = s | (<<i);
if(dp[s]+dp2[s] < dp[nexs]) {
dp[nexs] = dp[s]+dp2[s];
pre[nexs] = s;
}
}
}
int nows = up-, nexs;
while(nows) {
nexs = pre[nows];
int xo = nexs ^ nows;
for(int i = ; i < m; i++) {
if(<<i == xo) {
ans.push_back(i+);
break;
}
}
nows = nexs;
}
reverse(ans.begin(), ans.end());
printf("%d\n", dp[up-]);
for(int t : ans) printf("%d ", t);
puts("");
}
return ;
}
/*
*/

最新文章

  1. HTTP权威指南-基础知识
  2. java多线程-读写锁
  3. DOM--2 创建可重用的对象
  4. webshell
  5. mysql及redis环境部署时遇到的问题解决
  6. JavaScript DOM高级程序设计 4.3控制事件流和注册事件侦听器--我要坚持到底!
  7. (转)IOS 学习笔记 2015-03-23 如何获取IOS程序的系统信息
  8. Unity 图片的灰度处理
  9. ContentProvider中的数据生成时机
  10. Java中取某一个范围的随机数
  11. 【转载】Stack Overflow: The Architecture - 2016 Edition
  12. Excel单元格所在的行和列变色
  13. HTML,JS禁止鼠标右键、禁止全选、复制、粘贴的方法
  14. SQL优化及注意事项
  15. ST-LINK V2 DIY笔记(一)
  16. python基础(1)
  17. JSP报错:The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path
  18. python 前面几个单词含义
  19. Eclipse中jsp和html格式化自动排版问题
  20. JS循环语句!

热门文章

  1. 51 nod 1243 排船的问题
  2. codevs 3152 装箱问题3
  3. 《A First Course in Abstract Algebra with Applications》-chaper1-数论-棣莫弗定理
  4. python学习笔记3-函数,判断负小数
  5. idea 常用快捷使用
  6. [整理]C语言中字符常量与ASCII码
  7. 可简单避免的三个 JavaScript 发布错误
  8. don&#39;t run elasticsearch as root.
  9. mysql 时区设置
  10. 50、多线程创建的三种方式之实现Runnable接口