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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

d = A("d")
b = B("b")
h = C("h")
k = D("k")
i = E("i")
a = D("a")
n = C("n")
g = B("g")

d.r = n
b.y = k
h.u = g
h.p = k
h.z = k
k.v = i
k.u = h
i.v = a
a.v = i
a.u = n
n.u = g
n.p = a
n.z = a
g.y = k
assert n.u.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

d = A("d")
b = B("b")
h = C("h")
k = D("k")
i = E("i")
a = D("a")
n = C("n")
g = B("g")

d.r = n
b.y = k
h.u = g
h.p = k
h.z = k
k.v = i
k.u = h
i.v = a
a.v = i
a.u = n
n.u = g
n.p = a
n.z = a
g.y = k
assert n.u.y.v.txt == "i"