The easiest thing could be to add (right before the line which fails):
std::cout << a << " " << p << " " << m << std::endl;
Try also:
and: