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

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

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

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

d.r = k
n.w = g
n.u = a
n.r = k
l.x = i
l.z = k
g.w = n
g.u = i
g.r = k
k.r = m
m.r = k
a.x = l
a.z = k
c.w = g
c.u = l
c.r = m
f.w = g
f.u = i
f.r = k
i.x = l
i.z = m
assert k.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

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

d.r = k
n.w = g
n.u = a
n.r = k
l.x = i
l.z = k
g.w = n
g.u = i
g.r = k
k.r = m
m.r = k
a.x = l
a.z = k
c.w = g
c.u = l
c.r = m
f.w = g
f.u = i
f.r = k
i.x = l
i.z = m
assert k.r.r.r.r.txt == "k"