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

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

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

class D:
    def __init__(self, txt: str):
        self.p: A = None
        self.u: A = None
        self.txt = txt

d = A("d")
l = B("l")
m = C("m")
k = D("k")
e = B("e")
g = A("g")

d.o = m
d.p = m
d.u = k
l.p = m
m.v = e
m.y = g
m.z = g
m.o = g
k.p = g
k.u = g
e.p = m
g.o = m
g.p = m
g.u = k
assert l.p.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: C = None
        self.u: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: A = None
        self.u: A = None
        self.txt = txt

d = A("d")
l = B("l")
m = C("m")
k = D("k")
e = B("e")
g = A("g")

d.o = m
d.p = m
d.u = k
l.p = m
m.v = e
m.y = g
m.z = g
m.o = g
k.p = g
k.u = g
e.p = m
g.o = m
g.p = m
g.u = k
assert l.p.v.p.txt == "m"