#include <bits/stdc++.h>
using namespace std;
const int MAX = 1010;
const int NONE = 0;
const int HAS_BACK = 1;
const int HAS_BACK_USED = 2;

char mat[2][MAX];
int n;
int dp[MAX][3][3]; // pos, top row state, bottom row state

int Go(int pos, int st0, int st1) {
  if (pos == n)
    return 0;
  int& ret = dp[pos][st0][st1];
  int cost, new_state;
  if (ret == -1) {
    ret = 1 << 30;
    if (mat[0][pos] == 'X') {
      if (mat[1][pos] == 'X') {
        ret = Go(pos+1, NONE, NONE);
      } else {
        if (st1 == NONE) {
          new_state = HAS_BACK;
          cost = 1;
        } else {
          new_state = st1;
          cost = 0;
        }
        ret = cost + Go(pos+1, NONE, new_state);
      }
    } else {
      if (mat[1][pos] == 'X') {
        if (st0 == NONE) {
          new_state = HAS_BACK;
          cost = 1;
        } else {
          new_state = st0;
          cost = 0;
        }
        ret = cost + Go(pos+1, new_state, NONE);
      } else {
        // both free squares.
        if (st0 != NONE && st1 != NONE) {
          ret = Go(pos+1, st0, st1);
        } else if (st0 == NONE && st1 == NONE) {
          // put on top row or bottom row
          ret = 1 + min(Go(pos+1, HAS_BACK_USED, NONE), Go(pos+1, NONE, HAS_BACK_USED));
        } else if (st0 != NONE) {
          if (st0 == HAS_BACK)
            ret = Go(pos+1, HAS_BACK_USED, NONE);
          ret = min(ret, 1 + Go(pos+1, st0, HAS_BACK));
        } else {
          if (st1 == HAS_BACK)
            ret = Go(pos+1, NONE, HAS_BACK_USED);
          ret = min(ret, 1 + Go(pos+1, HAS_BACK, st1));
        }
      }
    }
  }
  return ret;
}
int Solve() {
  scanf("%d %s %s", &n, mat[0], mat[1]);
  memset(dp, -1, sizeof dp);
  return Go(0, NONE, NONE);
}

int main() {
  int ntests;
  scanf("%d", &ntests);
  for (int nt = 1; nt <= ntests; ++nt) {
    printf("Case #%d: %d\n", nt, Solve());
  }
  return 0;
}
