#include <stdio.h>
#include <errno.h>
#include <stdlib.h>

int main()
{
  char *s = "-1d+10h+5m-1s+1h-10m";
  long x;
  errno = 0;
  while ( x = strtol(s, &s, 10), x!=0 && errno == 0)
    printf("%ld%c", x,*s++);
  return 0;
}
