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

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

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

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

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

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

n.t = f
n.q = f
n.y = i
n.w = d
i.y = g
i.z = n
i.w = d
i.s = f
f.w = d
g.x = f
g.v = n
d.x = n
assert g.x.w.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.q: C = None
        self.y: B = None
        self.w: E = None
        self.txt = txt

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

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

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

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

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

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