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

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

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

m = A("m")
f = B("f")
n = C("n")
l = C("l")
h = B("h")
i = C("i")
g = A("g")
d = C("d")
c = C("c")
k = C("k")

m.r = h
m.o = h
m.w = h
f.q = l
f.w = h
n.r = k
l.r = i
h.q = l
h.w = f
i.r = d
g.r = h
g.w = h
g.o = f
d.r = k
c.r = n
k.r = c
assert k.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.o: B = None
        self.w: B = None
        self.txt = txt

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

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

m = A("m")
f = B("f")
n = C("n")
l = C("l")
h = B("h")
i = C("i")
g = A("g")
d = C("d")
c = C("c")
k = C("k")

m.r = h
m.o = h
m.w = h
f.q = l
f.w = h
n.r = k
l.r = i
h.q = l
h.w = f
i.r = d
g.r = h
g.w = h
g.o = f
d.r = k
c.r = n
k.r = c
assert k.r.r.r.txt == "k"