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

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

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

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

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

f = A("f")
c = B("c")
a = C("a")
b = D("b")
e = E("e")

f.r = b
c.y = b
a.t = b
a.y = b
a.w = c
a.x = f
a.u = e
b.z = e
b.t = f
e.y = a
assert f.r.z.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

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

f = A("f")
c = B("c")
a = C("a")
b = D("b")
e = E("e")

f.r = b
c.y = b
a.t = b
a.y = b
a.w = c
a.x = f
a.u = e
b.z = e
b.t = f
e.y = a
assert f.r.z.y.t.txt == "b"