```python
import re


def dose_totals(log):
    """Exact per-reagent totals of a pour log, counted in thousandths."""
    thousandths = {}
    places = {}
    for reagent, amount in log:
        written = re.fullmatch(r"-?\d+(?:\.(\d{1,3}))?", amount)
        if written is None:
            raise ValueError("amount is not a decimal of at most three places: " + amount)
        digits = written.group(1) or ""
        sign = -1 if amount.startswith("-") else 1
        bare = amount.replace("-", "").replace(".", "")
        thousandths[reagent] = thousandths.get(reagent, 0) + sign * int(bare) * 10 ** (3 - len(digits))
        places[reagent] = max(places.get(reagent, 0), len(digits))
    totals = {}
    for reagent in thousandths:
        total = thousandths[reagent]
        if total == 0:
            totals[reagent] = "0"
        else:
            decimal_places = 3 - places[reagent]
            if decimal_places == 0:
                totals[reagent] = str(total)
            else:
                total_str = str(total)
                if total_str[decimal_places] == "0":
                    total_str = total_str[:-decimal_places]
                totals[reagent] = f"{total_str:.{decimal_places}f}"
    return totals
```