class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.y: 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.o: C = None
        self.txt = txt

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

g.v = m
g.y = m
i.z = h
i.p = e
e.o = m
h.v = e
h.y = e
f.v = e
f.y = m
n.z = j
n.p = m
m.o = e
d.z = h
d.p = e
j.v = m
j.y = e
assert n.p.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.y: 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.o: C = None
        self.txt = txt

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

g.v = m
g.y = m
i.z = h
i.p = e
e.o = m
h.v = e
h.y = e
f.v = e
f.y = m
n.z = j
n.p = m
m.o = e
d.z = h
d.p = e
j.v = m
j.y = e
assert n.p.o.o.txt == "m"