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

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

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

k = A("k")
j = B("j")
l = C("l")
c = A("c")
n = B("n")
m = C("m")
f = A("f")

k.z = j
k.w = l
j.x = k
j.w = m
l.w = m
l.u = m
l.r = f
c.z = j
c.w = l
n.x = f
n.w = l
m.w = l
m.u = l
m.r = c
f.z = j
f.w = l
assert l.w.r.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: C = None
        self.txt = txt

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

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

k = A("k")
j = B("j")
l = C("l")
c = A("c")
n = B("n")
m = C("m")
f = A("f")

k.z = j
k.w = l
j.x = k
j.w = m
l.w = m
l.u = m
l.r = f
c.z = j
c.w = l
n.x = f
n.w = l
m.w = l
m.u = l
m.r = c
f.z = j
f.w = l
assert l.w.r.w.r.txt == "f"