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

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

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

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

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

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

e.r = g
a.y = j
a.q = k
h.v = j
h.z = e
g.x = h
k.u = e
c.x = h
j.v = h
j.z = e
assert g.x.v.z.r.x.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

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

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

e.r = g
a.y = j
a.q = k
h.v = j
h.z = e
g.x = h
k.u = e
c.x = h
j.v = h
j.z = e
assert g.x.v.z.r.x.v.v.txt == "h"