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

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

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

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

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

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

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

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

f.z = g
f.q = j
f.p = c
j.q = g
j.u = n
j.v = h
h.r = k
h.w = j
c.z = n
c.q = d
c.p = f
k.q = n
k.u = g
k.v = h
d.q = c
d.u = g
d.v = h
n.z = g
n.q = a
n.p = c
a.q = g
a.u = n
a.v = h
g.z = c
g.q = a
g.p = f
assert k.v.w.u.z.p.q.txt == "j"