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

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

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.v: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.v: D = None
        self.r: B = None
        self.y: B = None
        self.txt = txt

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

g.o = m
g.u = h
g.y = n
m.o = n
i.p = j
i.v = c
c.z = m
c.r = m
c.y = m
c.v = e
e.z = m
e.r = m
e.y = m
e.v = c
n.o = m
n.u = h
n.y = g
j.z = m
j.r = m
j.y = m
j.v = c
d.z = m
d.r = m
d.y = m
d.v = c
h.p = j
h.v = d
assert m.o.u.v.r.o.y.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: C = None
        self.y: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.v: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.v: D = None
        self.r: B = None
        self.y: B = None
        self.txt = txt

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

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