from typing import List
from typing import Tuple


def run_program(instructions: List[Tuple[str, str]]) -> Tuple[bool, int]:
    """Runs the program contained in `instructions` and returns a tuple
    representing whether it terminates and the value of its accumulator
    immediately before terminating or looping.
    """
    lines_visited = set()
    acc = 0
    ln = 0
    while ln not in lines_visited:
        lines_visited.add(ln)
        if ln >= len(instructions):
            return True, acc
        if instructions[ln][0] == 'jmp':
            ln += int(instructions[ln][1])
            continue
        if instructions[ln][0] == 'acc':
            acc += int(instructions[ln][1])
        ln += 1
    return False, acc