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

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

l = A("l")
i = B("i")
f = A("f")
m = B("m")
n = A("n")
d = B("d")

l.t = f
l.u = m
i.t = f
i.s = m
f.t = n
f.u = m
m.t = n
m.s = i
n.t = f
n.u = d
d.t = f
d.s = i
assert m.s.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.u: B = None
        self.txt = txt

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

l = A("l")
i = B("i")
f = A("f")
m = B("m")
n = A("n")
d = B("d")

l.t = f
l.u = m
i.t = f
i.s = m
f.t = n
f.u = m
m.t = n
m.s = i
n.t = f
n.u = d
d.t = f
d.s = i
assert m.s.t.t.txt == "n"