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

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

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

m = A("m")
k = B("k")
j = C("j")
n = A("n")
h = A("h")
b = B("b")
e = A("e")

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

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

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

m = A("m")
k = B("k")
j = C("j")
n = A("n")
h = A("h")
b = B("b")
e = A("e")

m.y = j
m.p = h
k.q = j
k.u = e
k.v = m
j.z = k
n.y = j
n.p = m
h.y = j
h.p = e
b.q = j
b.u = m
b.v = e
e.y = j
e.p = m
assert n.y.z.q.z.q.z.u.txt == "e"