fork download
  1. #include<iostream>
  2. #include<math.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int t;
  8. cin >> t;
  9. long long int n, m;
  10. char b[100001];
  11. long long int a[100001] = { 0 };
  12. long long int ans = 1;
  13. long long int z = pow(10, 9) + 9;
  14. while (t--)
  15. {
  16. cin >> n >> m;
  17. ans = 1;
  18. for (int i = 0; i<m; i++)
  19. {
  20. cin >> b[i] >> a[i];
  21. }
  22.  
  23. for (int i = 0; i<m - 1; i++)
  24. {
  25. if (b[i] == b[i + 1])
  26. ans *= 1;
  27. else
  28. ans = (ans*(a[i + 1] - a[i]))%z;
  29. }
  30.  
  31. cout << ans << endl;
  32.  
  33. }
  34. return 0;
  35. }
Success #stdin #stdout 0s 4096KB
stdin
1
7 3
A 7
B 1
C 4
stdout
-18