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

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

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

n = A("n")
d = B("d")
m = C("m")
j = C("j")
c = C("c")
k = C("k")

n.q = k
n.y = d
d.x = k
d.o = j
m.w = k
j.w = c
c.w = m
k.w = c
assert n.y.o.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: B = None
        self.txt = txt

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

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

n = A("n")
d = B("d")
m = C("m")
j = C("j")
c = C("c")
k = C("k")

n.q = k
n.y = d
d.x = k
d.o = j
m.w = k
j.w = c
c.w = m
k.w = c
assert n.y.o.w.w.w.w.txt == "c"