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

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

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

d = A("d")
b = B("b")
f = C("f")
l = D("l")
a = A("a")
g = B("g")
m = B("m")
e = D("e")

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

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

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

d = A("d")
b = B("b")
f = C("f")
l = D("l")
a = A("a")
g = B("g")
m = B("m")
e = D("e")

d.p = g
d.z = m
d.u = f
d.v = a
b.y = a
f.o = e
l.t = m
a.p = m
a.z = b
a.u = f
a.v = d
g.y = d
m.y = a
e.t = m
assert g.y.z.y.z.y.txt == "a"