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

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

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

b = A("b")
n = B("n")
l = C("l")
g = C("g")
d = B("d")
f = A("f")
e = A("e")

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

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

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

b = A("b")
n = B("n")
l = C("l")
g = C("g")
d = B("d")
f = A("f")
e = A("e")

b.r = n
b.u = n
n.s = b
n.t = d
l.q = e
l.s = g
g.q = e
g.s = l
d.s = b
d.t = n
f.r = d
f.u = d
e.r = n
e.u = d
assert l.q.r.s.u.s.txt == "b"