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

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

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

l = A("l")
i = B("i")
n = C("n")
h = B("h")
d = C("d")
f = B("f")
k = A("k")
g = C("g")
m = B("m")

l.r = k
l.q = k
l.z = m
i.y = m
i.w = l
i.v = k
n.z = m
n.y = l
h.y = i
h.w = k
h.v = k
d.z = m
d.y = k
f.y = h
f.w = k
f.v = l
k.r = l
k.q = l
k.z = i
g.z = i
g.y = k
m.y = f
m.w = l
m.v = l
assert k.r.q.q.q.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: A = None
        self.z: B = None
        self.txt = txt

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

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

l = A("l")
i = B("i")
n = C("n")
h = B("h")
d = C("d")
f = B("f")
k = A("k")
g = C("g")
m = B("m")

l.r = k
l.q = k
l.z = m
i.y = m
i.w = l
i.v = k
n.z = m
n.y = l
h.y = i
h.w = k
h.v = k
d.z = m
d.y = k
f.y = h
f.w = k
f.v = l
k.r = l
k.q = l
k.z = i
g.z = i
g.y = k
m.y = f
m.w = l
m.v = l
assert k.r.q.q.q.r.r.r.r.txt == "k"