class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: D = None
        self.q: E = None
        self.z: B = None
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: E = 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.v: A = None
        self.s: A = None
        self.w: E = None
        self.z: B = None
        self.r: E = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: E = 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.v: A = None
        self.s: A = None
        self.w: E = None
        self.z: B = None
        self.r: E = None
        self.txt = txt

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

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

b.v = i
b.z = i
b.y = d
b.r = d
b.q = n
i.y = b
i.p = n
g.o = b
d.v = b
d.s = b
d.w = n
d.r = n
d.z = i
n.q = i
n.w = i
n.z = d
n.v = b
assert d.z.p.v.txt == "b"