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

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

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

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

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

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

j.x = h
j.t = h
e.x = l
e.y = l
h.x = j
h.t = j
l.x = e
l.y = e
assert j.t.x.t.x.txt == "j"