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

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

h = A("h")
j = B("j")
e = A("e")

h.t = e
j.y = e
j.p = h
e.t = h
assert h.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

h = A("h")
j = B("j")
e = A("e")

h.t = e
j.y = e
j.p = h
e.t = h
assert h.t.t.t.txt == "e"