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

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

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

d = A("d")
h = B("h")
g = C("g")
e = C("e")
a = C("a")
f = C("f")
c = C("c")
k = A("k")
n = B("n")

d.r = k
d.o = k
h.u = n
h.w = a
g.q = k
g.z = h
e.q = k
e.z = n
a.q = k
a.z = h
f.q = d
f.z = n
c.q = k
c.z = n
k.r = d
k.o = d
n.u = h
n.w = f
assert c.z.u.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: A = None
        self.txt = txt

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

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

d = A("d")
h = B("h")
g = C("g")
e = C("e")
a = C("a")
f = C("f")
c = C("c")
k = A("k")
n = B("n")

d.r = k
d.o = k
h.u = n
h.w = a
g.q = k
g.z = h
e.q = k
e.z = n
a.q = k
a.z = h
f.q = d
f.z = n
c.q = k
c.z = n
k.r = d
k.o = d
n.u = h
n.w = f
assert c.z.u.w.q.txt == "k"