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

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

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

class D:
    def __init__(self, txt: str):
        self.v: E = None
        self.t: E = None
        self.s: A = None
        self.q: B = None
        self.txt = txt

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

n = A("n")
b = B("b")
i = C("i")
d = D("d")
f = E("f")

n.r = d
b.v = n
b.u = i
b.y = i
b.t = f
i.z = f
d.v = f
d.t = f
d.s = n
d.q = b
f.w = n
f.y = d
f.x = i
assert d.s.r.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: E = None
        self.t: E = None
        self.s: A = None
        self.q: B = None
        self.txt = txt

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

n = A("n")
b = B("b")
i = C("i")
d = D("d")
f = E("f")

n.r = d
b.v = n
b.u = i
b.y = i
b.t = f
i.z = f
d.v = f
d.t = f
d.s = n
d.q = b
f.w = n
f.y = d
f.x = i
assert d.s.r.v.x.txt == "i"