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

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

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

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

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

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

a.x = f
a.v = l
d.x = l
d.p = a
g.u = f
l.z = f
f.x = d
f.r = d
f.q = g
f.p = g
f.t = l
assert f.t.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.v: D = None
        self.txt = txt

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

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

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

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

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

a.x = f
a.v = l
d.x = l
d.p = a
g.u = f
l.z = f
f.x = d
f.r = d
f.q = g
f.p = g
f.t = l
assert f.t.z.r.txt == "d"