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

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

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.s: B = None
        self.z: D = None
        self.txt = txt

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

k = A("k")
m = B("m")
a = C("a")
d = D("d")
c = B("c")
j = A("j")
b = A("b")
f = D("f")

k.v = m
k.u = j
k.r = a
k.o = a
m.z = d
m.v = c
m.r = a
m.t = j
a.x = f
a.z = f
a.s = c
d.r = a
d.p = f
c.z = f
c.v = m
c.r = a
c.t = j
j.v = m
j.u = k
j.r = a
j.o = a
b.v = m
b.u = k
b.r = a
b.o = a
f.r = a
f.p = d
assert j.u.r.z.r.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: A = None
        self.r: C = None
        self.o: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.s: B = None
        self.z: D = None
        self.txt = txt

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

k = A("k")
m = B("m")
a = C("a")
d = D("d")
c = B("c")
j = A("j")
b = A("b")
f = D("f")

k.v = m
k.u = j
k.r = a
k.o = a
m.z = d
m.v = c
m.r = a
m.t = j
a.x = f
a.z = f
a.s = c
d.r = a
d.p = f
c.z = f
c.v = m
c.r = a
c.t = j
j.v = m
j.u = k
j.r = a
j.o = a
b.v = m
b.u = k
b.r = a
b.o = a
f.r = a
f.p = d
assert j.u.r.z.r.x.p.txt == "d"