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

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

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

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

d.q = e
d.v = n
e.z = d
e.p = n
c.u = d
c.y = h
c.o = n
k.z = d
k.p = n
n.u = m
n.y = m
n.o = c
h.q = k
h.v = c
m.q = k
m.v = n
assert h.q.p.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: C = None
        self.txt = txt

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

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

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

d.q = e
d.v = n
e.z = d
e.p = n
c.u = d
c.y = h
c.o = n
k.z = d
k.p = n
n.u = m
n.y = m
n.o = c
h.q = k
h.v = c
m.q = k
m.v = n
assert h.q.p.y.v.txt == "n"