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

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

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

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

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

k = A("k")
i = B("i")
c = C("c")
l = D("l")
n = E("n")
j = E("j")
g = C("g")
h = A("h")
a = B("a")

k.z = h
i.v = a
c.y = j
c.x = g
l.r = h
l.y = a
n.o = a
n.v = a
j.o = a
j.v = i
g.y = j
g.x = c
h.z = k
a.v = i
assert a.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

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

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

k = A("k")
i = B("i")
c = C("c")
l = D("l")
n = E("n")
j = E("j")
g = C("g")
h = A("h")
a = B("a")

k.z = h
i.v = a
c.y = j
c.x = g
l.r = h
l.y = a
n.o = a
n.v = a
j.o = a
j.v = i
g.y = j
g.x = c
h.z = k
a.v = i
assert a.v.v.v.v.v.v.txt == "a"