class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: A = None
        self.txt = txt

h = A("h")
c = B("c")
a = A("a")
i = B("i")

h.p = a
c.s = a
c.t = a
a.p = h
i.s = a
i.t = a
assert c.t.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: A = None
        self.txt = txt

h = A("h")
c = B("c")
a = A("a")
i = B("i")

h.p = a
c.s = a
c.t = a
a.p = h
i.s = a
i.t = a
assert c.t.p.p.p.txt == "h"