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

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

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

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

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

h = A("h")
d = B("d")
a = C("a")
j = D("j")
g = E("g")

h.q = d
h.x = g
d.q = h
d.v = h
d.x = g
a.o = g
a.w = d
a.y = d
a.p = h
j.s = a
j.x = h
g.w = h
g.z = h
assert a.p.x.z.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: E = None
        self.txt = txt

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

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

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

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

h = A("h")
d = B("d")
a = C("a")
j = D("j")
g = E("g")

h.q = d
h.x = g
d.q = h
d.v = h
d.x = g
a.o = g
a.w = d
a.y = d
a.p = h
j.s = a
j.x = h
g.w = h
g.z = h
assert a.p.x.z.q.x.txt == "g"