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

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

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

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

d = A("d")
g = B("g")
j = C("j")
m = D("m")
i = B("i")
k = C("k")
b = A("b")

d.w = m
d.v = j
d.t = j
d.o = b
g.w = i
g.z = i
g.x = b
g.o = b
j.x = k
j.r = b
m.x = k
m.o = k
i.w = g
i.z = g
i.x = b
i.o = d
k.x = j
k.r = b
b.w = m
b.v = j
b.t = j
b.o = d
assert k.x.r.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.v: C = None
        self.t: C = None
        self.o: A = None
        self.txt = txt

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

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

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

d = A("d")
g = B("g")
j = C("j")
m = D("m")
i = B("i")
k = C("k")
b = A("b")

d.w = m
d.v = j
d.t = j
d.o = b
g.w = i
g.z = i
g.x = b
g.o = b
j.x = k
j.r = b
m.x = k
m.o = k
i.w = g
i.z = g
i.x = b
i.o = d
k.x = j
k.r = b
b.w = m
b.v = j
b.t = j
b.o = d
assert k.x.r.v.x.txt == "k"