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

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

class C:
    def __init__(self, txt: str):
        self.q: E = None
        self.x: B = None
        self.u: B = None
        self.w: E = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
a = C("a")
l = D("l")
j = E("j")

f.x = j
f.y = j
f.r = a
m.r = a
a.q = j
a.w = j
a.x = m
a.u = m
l.t = m
l.z = j
j.w = a
assert j.w.q.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.y: E = None
        self.r: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: E = None
        self.x: B = None
        self.u: B = None
        self.w: E = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
a = C("a")
l = D("l")
j = E("j")

f.x = j
f.y = j
f.r = a
m.r = a
a.q = j
a.w = j
a.x = m
a.u = m
l.t = m
l.z = j
j.w = a
assert j.w.q.w.w.txt == "j"