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

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

l = A("l")
b = B("b")
d = B("d")
a = B("a")
e = A("e")
m = B("m")

l.s = e
l.t = a
b.t = l
b.q = d
d.t = l
d.q = a
a.t = l
a.q = b
e.s = l
e.t = d
m.t = e
m.q = a
assert m.t.t.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: B = None
        self.txt = txt

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

l = A("l")
b = B("b")
d = B("d")
a = B("a")
e = A("e")
m = B("m")

l.s = e
l.t = a
b.t = l
b.q = d
d.t = l
d.q = a
a.t = l
a.q = b
e.s = l
e.t = d
m.t = e
m.q = a
assert m.t.t.q.q.txt == "b"