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

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

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

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

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

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

a.r = g
a.q = h
k.p = j
k.x = h
j.q = k
j.z = g
j.x = b
b.u = g
b.w = h
g.p = j
g.u = h
h.r = g
h.q = a
assert a.r.p.q.p.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.q: A = None
        self.txt = txt

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

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

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

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

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

a.r = g
a.q = h
k.p = j
k.x = h
j.q = k
j.z = g
j.x = b
b.u = g
b.w = h
g.p = j
g.u = h
h.r = g
h.q = a
assert a.r.p.q.p.z.u.txt == "h"