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

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

e = A("e")
j = B("j")
h = A("h")
d = A("d")
g = B("g")
i = B("i")

e.x = h
e.t = g
j.u = e
h.x = d
h.t = i
d.x = e
d.t = g
g.u = d
i.u = d
assert e.t.u.x.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.t: B = None
        self.txt = txt

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

e = A("e")
j = B("j")
h = A("h")
d = A("d")
g = B("g")
i = B("i")

e.x = h
e.t = g
j.u = e
h.x = d
h.t = i
d.x = e
d.t = g
g.u = d
i.u = d
assert e.t.u.x.x.t.txt == "i"