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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.o: A = 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: B = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.o: A = 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: B = None
        self.txt = txt

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

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

a.q = j
a.y = g
a.p = n
g.q = n
g.o = a
c.o = a
n.v = g
j.s = g
j.x = n
j.w = c
assert c.o.p.v.q.v.txt == "g"