class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: B = None
        self.y: D = None
        self.q: A = None
        self.txt = txt

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

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

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

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

j.w = m
j.x = a
j.y = b
j.q = k
d.x = a
d.o = j
d.v = b
m.x = d
m.z = k
m.o = k
i.p = b
i.u = j
i.v = f
k.w = g
k.x = d
k.y = i
k.q = j
f.x = d
f.z = k
f.o = j
g.x = d
g.z = k
g.o = k
b.p = i
b.u = j
b.v = f
a.x = d
a.o = k
a.v = i
assert b.v.x.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: B = None
        self.y: D = None
        self.q: A = None
        self.txt = txt

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

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

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

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

j.w = m
j.x = a
j.y = b
j.q = k
d.x = a
d.o = j
d.v = b
m.x = d
m.z = k
m.o = k
i.p = b
i.u = j
i.v = f
k.w = g
k.x = d
k.y = i
k.q = j
f.x = d
f.z = k
f.o = j
g.x = d
g.z = k
g.o = k
b.p = i
b.u = j
b.v = f
a.x = d
a.o = k
a.v = i
assert b.v.x.v.v.txt == "f"