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

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

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

m = A("m")
h = B("h")
n = C("n")
g = B("g")
i = B("i")
e = C("e")
f = A("f")

m.q = h
m.r = e
m.z = f
h.z = e
h.s = i
h.w = m
n.v = f
n.t = e
n.y = g
g.z = n
g.s = i
g.w = f
i.z = e
i.s = g
i.w = f
e.v = m
e.t = n
e.y = i
f.q = h
f.r = n
f.z = m
assert n.y.w.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: C = None
        self.z: A = None
        self.txt = txt

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

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

m = A("m")
h = B("h")
n = C("n")
g = B("g")
i = B("i")
e = C("e")
f = A("f")

m.q = h
m.r = e
m.z = f
h.z = e
h.s = i
h.w = m
n.v = f
n.t = e
n.y = g
g.z = n
g.s = i
g.w = f
i.z = e
i.s = g
i.w = f
e.v = m
e.t = n
e.y = i
f.q = h
f.r = n
f.z = m
assert n.y.w.r.y.txt == "g"