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

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

d = A("d")
e = B("e")
g = B("g")
l = B("l")

d.q = e
e.s = g
e.u = l
g.s = l
g.u = e
l.s = e
l.u = e
assert e.s.u.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

d = A("d")
e = B("e")
g = B("g")
l = B("l")

d.q = e
e.s = g
e.u = l
g.s = l
g.u = e
l.s = e
l.u = e
assert e.s.u.s.u.txt == "e"