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

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.q: D = None
        self.s: B = None
        self.txt = txt

a = A("a")
d = B("d")
j = C("j")
g = D("g")
i = E("i")
f = D("f")

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

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.q: D = None
        self.s: B = None
        self.txt = txt

a = A("a")
d = B("d")
j = C("j")
g = D("g")
i = E("i")
f = D("f")

a.w = f
a.o = d
a.y = d
d.z = i
j.s = a
j.p = a
j.v = a
j.z = d
g.v = j
g.x = j
g.w = a
i.q = g
i.s = d
f.v = j
f.x = j
f.w = a
assert i.s.z.s.txt == "d"