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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: D = None
        self.w: E = None
        self.t: A = None
        self.p: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: C = None
        self.t: C = None
        self.txt = txt

f = A("f")
m = B("m")
a = C("a")
d = D("d")
n = E("n")

f.y = d
f.w = m
m.v = d
a.q = f
a.t = f
a.x = d
a.w = n
a.p = n
d.v = a
d.p = m
n.p = a
n.u = a
n.t = a
assert a.t.y.v.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: D = None
        self.w: E = None
        self.t: A = None
        self.p: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: C = None
        self.t: C = None
        self.txt = txt

f = A("f")
m = B("m")
a = C("a")
d = D("d")
n = E("n")

f.y = d
f.w = m
m.v = d
a.q = f
a.t = f
a.x = d
a.w = n
a.p = n
d.v = a
d.p = m
n.p = a
n.u = a
n.t = a
assert a.t.y.v.q.y.txt == "d"