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

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.s: B = None
        self.p: D = None
        self.z: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: E = None
        self.x: E = None
        self.z: B = None
        self.u: E = None
        self.txt = txt

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

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

b.z = n
a.r = c
n.w = b
n.s = a
n.p = c
n.z = c
c.s = a
c.z = a
c.w = f
c.x = f
c.u = f
f.y = a
assert a.r.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.s: B = None
        self.p: D = None
        self.z: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: E = None
        self.x: E = None
        self.z: B = None
        self.u: E = None
        self.txt = txt

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

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

b.z = n
a.r = c
n.w = b
n.s = a
n.p = c
n.z = c
c.s = a
c.z = a
c.w = f
c.x = f
c.u = f
f.y = a
assert a.r.x.y.txt == "a"