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

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

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

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.r: C = None
        self.u: A = None
        self.txt = txt

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

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

a.r = k
l.v = k
l.x = a
f.w = k
f.y = k
f.r = a
g.z = a
g.u = a
g.r = f
k.z = f
k.x = a
k.v = a
assert a.r.z.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.r: C = None
        self.u: A = None
        self.txt = txt

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

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

a.r = k
l.v = k
l.x = a
f.w = k
f.y = k
f.r = a
g.z = a
g.u = a
g.r = f
k.z = f
k.x = a
k.v = a
assert a.r.z.y.v.txt == "a"