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

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

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

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

d = A("d")
g = B("g")
n = C("n")
j = D("j")
m = D("m")
l = A("l")

d.z = g
d.t = n
d.o = l
d.x = l
g.w = d
g.o = d
g.x = n
g.t = n
n.o = m
n.y = m
j.v = m
j.u = g
m.v = j
m.u = g
l.z = g
l.t = n
l.o = d
l.x = d
assert n.y.u.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: C = None
        self.o: A = None
        self.x: A = None
        self.txt = txt

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

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

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

d = A("d")
g = B("g")
n = C("n")
j = D("j")
m = D("m")
l = A("l")

d.z = g
d.t = n
d.o = l
d.x = l
g.w = d
g.o = d
g.x = n
g.t = n
n.o = m
n.y = m
j.v = m
j.u = g
m.v = j
m.u = g
l.z = g
l.t = n
l.o = d
l.x = d
assert n.y.u.w.x.txt == "l"