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

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

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

a = A("a")
h = B("h")
l = C("l")
f = B("f")
n = B("n")
k = A("k")
b = C("b")
d = C("d")
c = A("c")
m = A("m")

a.z = h
a.w = f
a.q = f
h.v = f
h.x = a
l.w = b
l.r = m
f.v = h
f.x = a
n.v = h
n.x = m
k.z = n
k.w = n
k.q = n
b.w = d
b.r = k
d.w = l
d.r = k
c.z = n
c.q = n
c.w = f
m.z = h
m.w = h
m.q = h
assert f.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: B = None
        self.q: B = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
l = C("l")
f = B("f")
n = B("n")
k = A("k")
b = C("b")
d = C("d")
c = A("c")
m = A("m")

a.z = h
a.w = f
a.q = f
h.v = f
h.x = a
l.w = b
l.r = m
f.v = h
f.x = a
n.v = h
n.x = m
k.z = n
k.w = n
k.q = n
b.w = d
b.r = k
d.w = l
d.r = k
c.z = n
c.q = n
c.w = f
m.z = h
m.w = h
m.q = h
assert f.v.v.v.txt == "h"