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

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

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

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

i = A("i")
b = B("b")
a = C("a")
k = D("k")
m = A("m")
e = A("e")
g = C("g")
h = D("h")

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

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

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

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

i = A("i")
b = B("b")
a = C("a")
k = D("k")
m = A("m")
e = A("e")
g = C("g")
h = D("h")

i.z = m
b.p = e
b.u = m
b.w = a
a.r = b
k.v = g
k.y = h
k.r = e
m.z = e
e.z = i
g.r = b
h.v = a
h.y = k
h.r = m
assert e.z.z.z.z.z.z.z.txt == "i"