You extract role history from German Handelsregister CD table text.

The input contains only relevant CD entries. Read the entries in chronological order.

Main task:
Reconstruct role intervals, not isolated text mentions.

A role interval is one continuous period where one person holds one role.

Role interval rules:
- An appointment/start entry opens a new role interval.
- A removal/end entry closes an existing role interval.
- If the same person is appointed again after a previous removal, create a new role interval.
- If the same person changes from Geschäftsführer or Vorstand to Liquidator, close the old role interval at that entry date and open a new Liquidator interval at the same entry date.
- A data-change entry updates the same role interval and must not create a duplicate.
- Data-change entries may update only name, title, birth_date, city, or role wording if explicitly shown.
- Data-change entries must not change start_date.
- Data-change entries must not set end_date.
- "Geändert, nunmehr:", "Vertretungsbefugnis geändert, nun:", "Nach Berichtigung von Amts wegen:", "berichtigt" and similar wording are data-change entries, not new appointments.

Event heading scope:
- A heading such as "Bestellt:", "Ausgeschieden:", "Nicht mehr ..." applies to all following person lines in the same block until another event heading or the next Entry starts.
- If two or more persons are listed under one appointment heading, each of them starts at that same entry date.
- If two or more persons are listed under one removal heading, each of them ends at that same entry date.

Date rules:
- Entry dates are written on a separate line as "Entry date: DD.MM.YYYY".
- Copy start_date and end_date only from the "Entry date:" line.
- Do not use the Entry number as part of a date.
- start_date is set only from the appointment/start entry of this role interval.
- end_date is set only from the removal/end entry, or from a role change such as becoming Liquidator.
- If no appointment/start entry is present, start_date is null.
- If the role has not ended, end_date is null.

Field rules:
- name: person's name only, without title, city, birth date, role, or representation text. Keep the source order and keep all name parts, for example "Hartmann, Karl Leopold".
- Do not shorten multi-part given names. Example: "Hartmann, Karl Leopold" must stay "Hartmann, Karl Leopold", not "Hartmann, Karl".
- title: academic or professional title as one string, for example "Dr.", "Prof. Dr.", "Dipl.-Kfm."; if no title is present, use null.
- If a person line starts with a title, remove the title from name and put it only into title.
- Never duplicate a title in both name and title. Example: "Dr. Berger, Clara, Bonn, *03.03.1973" -> name "Berger, Clara", title "Dr.".
- birth_date: keep DD.MM.YYYY format if present, otherwise null.
- city: person's full residence string if present, otherwise null. Keep country or region parts, for example "Wels / Österreich".
- role: clean role label, for example "Geschäftsführer", "Vorstand", "Liquidator".
- status: "active" if end_date is null, otherwise "ended".
- initial_marker: true if this role object is first seen in Entry 1, otherwise false.
- initial_marker does not mean "first item in the output list". If several role objects are first seen in Entry 1, all of them must have initial_marker true.

Personal data rules:
- For each role interval, keep the latest known value for name, title, birth_date, and city.
- A later relevant entry may update a field if it shows a new value.
- If a later relevant entry omits a field, keep the previous known value for that field.
- Do not replace a known name, title, birth_date, or city with null only because it is missing in a later entry.
- For ended roles, prefer personal data from the ending entry, but only for fields that are actually shown there.
- Do not shorten residence strings. If the input says "Wels / Österreich", return "Wels / Österreich", not only "Wels" or "Österreich".
- Do not create a new role only because city, title, name, or birth_date changed.
- If a birth_date is corrected later and the name/context matches, update the same person instead of creating a new person.

Person matching:
Use all available evidence to decide whether mentions refer to the same person:
- same name
- same role
- same birth_date
- wording such as Geändert, nunmehr, berichtigt, weiterhin

Do not rely only on birth_date.
Do not create roles from general representation rules only.

Example 1 input:
## Entry 1
Entry date: 02.02.2020
Bestellt:
Geschäftsführer:
Hartmann, Karl Leopold, Köln, *01.01.1970
Dr. Berger, Clara, Hamburg, *03.03.1973

## Entry 3
Entry date: 04.04.2021
Geändert, nunmehr:
Geschäftsführer:
Dr. Berger, Clara, Berlin, *03.03.1973

## Entry 4
Entry date: 05.05.2022
Ausgeschieden:
Geschäftsführer:
Hartmann, Karl Leopold, Bonn, *01.01.1970
Dr. Berger, Clara, Berlin, *03.03.1973

Example 1 output:
{
  "roles": [
    {
      "name": "Hartmann, Karl Leopold",
      "title": null,
      "birth_date": "01.01.1970",
      "city": "Bonn",
      "role": "Geschäftsführer",
      "start_date": "02.02.2020",
      "end_date": "05.05.2022",
      "status": "ended",
      "initial_marker": true
    },
    {
      "name": "Berger, Clara",
      "title": "Dr.",
      "birth_date": "03.03.1973",
      "city": "Berlin",
      "role": "Geschäftsführer",
      "start_date": "02.02.2020",
      "end_date": "05.05.2022",
      "status": "ended",
      "initial_marker": true
    }
  ]
}

Example 2 input:
## Entry 1
Entry date: 10.10.2020
Nicht mehr Vorstand:
Schmitt, Marie, Essen, *10.10.1975

## Entry 2
Entry date: 20.10.2020
Bestellt:
Vorstand:
Schmitt, Marie, Düsseldorf, *10.10.1975

## Entry 3
Entry date: 15.03.2021
Nach Berichtigung von Amts wegen:
Vorstand:
Schmitt, Marie, Düsseldorf, *10.10.1974

Example 2 output:
{
  "roles": [
    {
      "name": "Schmitt, Marie",
      "title": null,
      "birth_date": "10.10.1975",
      "city": "Essen",
      "role": "Vorstand",
      "start_date": null,
      "end_date": "10.10.2020",
      "status": "ended",
      "initial_marker": true
    },
    {
      "name": "Schmitt, Marie",
      "title": null,
      "birth_date": "10.10.1974",
      "city": "Düsseldorf",
      "role": "Vorstand",
      "start_date": "20.10.2020",
      "end_date": null,
      "status": "active",
      "initial_marker": false
    }
  ]
}

Example 3 input:
## Entry 31
Entry date: 25.04.2016
Bestellt:
Geschäftsführer:
Hofmann, Paul, Berlin, *29.04.1963
Braun, Jonas Leo, Pulheim, *17.04.1967

## Entry 42
Entry date: 11.02.2019
Vertretungsbefugnis geändert, nun:
Geschäftsführer:
Hofmann, Paul, *29.04.1963

## Entry 47
Entry date: 08.03.2021
Ausgeschieden:
Geschäftsführer:
Hofmann, Paul, *29.04.1963

## Entry 50
Entry date: 16.04.2021
Ausgeschieden:
Geschäftsführer:
Braun, Jonas Leo, Pulheim, *17.04.1967

Example 3 output:
{
  "roles": [
    {
      "name": "Hofmann, Paul",
      "title": null,
      "birth_date": "29.04.1963",
      "city": "Berlin",
      "role": "Geschäftsführer",
      "start_date": "25.04.2016",
      "end_date": "08.03.2021",
      "status": "ended",
      "initial_marker": false
    },
    {
      "name": "Braun, Jonas Leo",
      "title": null,
      "birth_date": "17.04.1967",
      "city": "Pulheim",
      "role": "Geschäftsführer",
      "start_date": "25.04.2016",
      "end_date": "16.04.2021",
      "status": "ended",
      "initial_marker": false
    }
  ]
}

Example 4 input:
## Entry 1
Entry date: 21.10.2014
Geschäftsführer:
Dr. Keller, Till, Hilchenbach, *16.12.1973

## Entry 2
Entry date: 09.01.2024
Geändert, nunmehr Liquidator:
Dr. Keller, Till, Wels / Österreich, *16.12.1973

Example 4 output:
{
  "roles": [
    {
      "name": "Keller, Till",
      "title": "Dr.",
      "birth_date": "16.12.1973",
      "city": "Wels / Österreich",
      "role": "Geschäftsführer",
      "start_date": "21.10.2014",
      "end_date": "09.01.2024",
      "status": "ended",
      "initial_marker": true
    },
    {
      "name": "Keller, Till",
      "title": "Dr.",
      "birth_date": "16.12.1973",
      "city": "Wels / Österreich",
      "role": "Liquidator",
      "start_date": "09.01.2024",
      "end_date": null,
      "status": "active",
      "initial_marker": false
    }
  ]
}
