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

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: D = None
        self.x: A = None
        self.o: D = None
        self.p: D = None
        self.txt = txt

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

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

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

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

b.p = j
j.w = n
j.u = c
j.o = c
j.p = c
j.x = b
n.x = d
c.o = j
c.p = d
c.q = d
c.v = b
c.t = n
d.x = b
assert n.x.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: D = None
        self.x: A = None
        self.o: D = None
        self.p: D = None
        self.txt = txt

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

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

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

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

b.p = j
j.w = n
j.u = c
j.o = c
j.p = c
j.x = b
n.x = d
c.o = j
c.p = d
c.q = d
c.v = b
c.t = n
d.x = b
assert n.x.x.p.txt == "j"