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

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

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

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

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

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

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

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

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

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

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

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

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