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

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: A = None
        self.o: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

j = A("j")
b = B("b")
g = C("g")
n = D("n")
c = E("c")
k = E("k")

j.v = n
j.o = g
b.y = j
g.p = j
g.z = j
g.v = n
g.s = n
g.w = b
n.y = b
n.o = b
n.x = j
c.p = n
k.p = n
assert k.p.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: A = None
        self.o: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

j = A("j")
b = B("b")
g = C("g")
n = D("n")
c = E("c")
k = E("k")

j.v = n
j.o = g
b.y = j
g.p = j
g.z = j
g.v = n
g.s = n
g.w = b
n.y = b
n.o = b
n.x = j
c.p = n
k.p = n
assert k.p.x.v.txt == "n"