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

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

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

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

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

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

e = A("e")
a = B("a")
l = C("l")
i = D("i")
m = E("m")
f = F("f")
h = C("h")
b = D("b")
k = B("k")

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

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

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

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

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

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

e = A("e")
a = B("a")
l = C("l")
i = D("i")
m = E("m")
f = F("f")
h = C("h")
b = D("b")
k = B("k")

e.x = a
a.w = i
l.z = e
l.p = e
l.w = e
i.r = e
m.z = k
m.u = f
m.y = b
f.x = e
h.z = e
h.p = e
h.w = e
b.r = e
k.w = b
assert k.w.r.x.w.r.x.w.r.x.txt == "a"