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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: A = None
        self.z: C = None
        self.v: B = None
        self.txt = txt

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

b.p = g
b.q = c
h.s = b
h.x = b
c.v = j
c.t = j
c.z = h
c.s = h
j.o = g
j.s = h
g.t = b
g.z = c
g.v = h
assert b.q.s.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.q: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: A = None
        self.z: C = None
        self.v: B = None
        self.txt = txt

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

b.p = g
b.q = c
h.s = b
h.x = b
c.v = j
c.t = j
c.z = h
c.s = h
j.o = g
j.s = h
g.t = b
g.z = c
g.v = h
assert b.q.s.x.q.txt == "c"