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

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

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

n = A("n")
b = B("b")
i = C("i")
c = B("c")
l = C("l")

n.q = l
n.w = l
b.r = n
i.r = n
i.y = l
c.r = n
l.r = n
l.y = i
assert l.y.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.w: C = None
        self.txt = txt

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

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

n = A("n")
b = B("b")
i = C("i")
c = B("c")
l = C("l")

n.q = l
n.w = l
b.r = n
i.r = n
i.y = l
c.r = n
l.r = n
l.y = i
assert l.y.y.r.txt == "n"