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

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

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

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

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

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

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

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

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

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

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

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

d.q = n
d.v = n
d.x = f
d.u = e
n.s = f
n.z = f
n.q = i
n.p = d
n.v = d
i.o = d
f.s = i
f.r = i
f.p = e
f.y = d
e.x = n
e.v = n
e.w = i
assert i.o.u.w.txt == "i"