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

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

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

b = A("b")
n = B("n")
c = C("c")
e = C("e")
l = A("l")
a = B("a")

b.x = a
n.s = b
n.r = c
c.q = e
e.q = c
l.x = a
a.s = b
a.r = c
assert b.x.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

b = A("b")
n = B("n")
c = C("c")
e = C("e")
l = A("l")
a = B("a")

b.x = a
n.s = b
n.r = c
c.q = e
e.q = c
l.x = a
a.s = b
a.r = c
assert b.x.r.q.txt == "e"