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

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

h = A("h")
e = B("e")
k = B("k")
a = B("a")

h.t = a
e.t = k
e.v = k
k.t = e
k.v = e
a.t = e
a.v = k
assert h.t.t.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

h = A("h")
e = B("e")
k = B("k")
a = B("a")

h.t = a
e.t = k
e.v = k
k.t = e
k.v = e
a.t = e
a.v = k
assert h.t.t.t.v.txt == "e"