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

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

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.z: B = None
        self.r: D = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.z: B = None
        self.r: D = None
        self.txt = txt

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

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

i.q = a
i.v = h
i.r = h
h.x = b
h.v = a
h.y = g
h.s = c
a.z = i
a.p = h
j.y = i
j.z = h
j.r = b
c.z = i
c.p = i
g.q = a
g.v = h
g.r = h
b.y = g
b.z = h
b.r = j
assert j.z.v.z.v.v.p.txt == "h"