#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int x;     cin >> x;     while (x--) {       int n, m, ans = 0;       cin >> n >> m;       char a[n][m];       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) cin >> a[i][j];       }       int i = n - 1;       for (int j = 0; j < m - 1; j++) {         if (a[i][j] ==  D ) ans++;       }       int j = m - 1;       for (i = 0; i < n - 1; i++) {         if (a[i][j] ==  R ) ans++;       }       cout << ans << endl;     }     return 0;   }   