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

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

l = A("l")
f = B("f")
i = B("i")
g = B("g")
n = A("n")
h = B("h")
b = B("b")

l.u = g
f.t = l
f.x = b
i.t = n
i.x = b
g.t = l
g.x = f
n.u = i
h.t = n
h.x = b
b.t = n
b.x = i
assert h.t.u.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

l = A("l")
f = B("f")
i = B("i")
g = B("g")
n = A("n")
h = B("h")
b = B("b")

l.u = g
f.t = l
f.x = b
i.t = n
i.x = b
g.t = l
g.x = f
n.u = i
h.t = n
h.x = b
b.t = n
b.x = i
assert h.t.u.x.t.txt == "n"