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

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: D = None
        self.txt = txt

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

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

d = A("d")
l = B("l")
i = C("i")
j = D("j")
h = C("h")
c = C("c")
k = B("k")
e = A("e")
f = D("f")
b = B("b")

d.o = k
d.x = j
l.x = d
l.r = f
i.z = e
i.t = b
j.w = h
j.p = h
j.v = f
h.z = d
h.t = l
c.z = d
c.t = l
k.x = e
k.r = f
e.o = b
e.x = f
f.w = i
f.p = h
f.v = j
b.x = e
b.r = j
assert j.p.t.r.v.v.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: D = None
        self.txt = txt

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

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

d = A("d")
l = B("l")
i = C("i")
j = D("j")
h = C("h")
c = C("c")
k = B("k")
e = A("e")
f = D("f")
b = B("b")

d.o = k
d.x = j
l.x = d
l.r = f
i.z = e
i.t = b
j.w = h
j.p = h
j.v = f
h.z = d
h.t = l
c.z = d
c.t = l
k.x = e
k.r = f
e.o = b
e.x = f
f.w = i
f.p = h
f.v = j
b.x = e
b.r = j
assert j.p.t.r.v.v.v.w.txt == "h"