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

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.s: B = None
        self.o: B = None
        self.t: B = None
        self.z: D = None
        self.txt = txt

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

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

i = A("i")
a = B("a")
g = C("g")
b = D("b")
j = E("j")

i.p = g
a.w = j
a.y = j
a.r = i
a.v = g
g.v = a
g.s = a
g.o = a
g.t = a
g.z = b
b.u = g
b.q = i
j.s = i
j.r = i
j.y = a
j.x = b
j.v = g
assert j.x.q.p.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.s: B = None
        self.o: B = None
        self.t: B = None
        self.z: D = None
        self.txt = txt

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

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

i = A("i")
a = B("a")
g = C("g")
b = D("b")
j = E("j")

i.p = g
a.w = j
a.y = j
a.r = i
a.v = g
g.v = a
g.s = a
g.o = a
g.t = a
g.z = b
b.u = g
b.q = i
j.s = i
j.r = i
j.y = a
j.x = b
j.v = g
assert j.x.q.p.v.v.txt == "g"