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

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

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

g = A("g")
j = B("j")
n = C("n")
d = C("d")
m = A("m")
k = A("k")
c = B("c")

g.s = n
j.v = c
j.z = k
n.w = k
n.t = d
n.r = d
d.w = m
d.t = n
d.r = n
m.s = d
k.s = d
c.v = j
c.z = g
assert k.s.t.w.s.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

g = A("g")
j = B("j")
n = C("n")
d = C("d")
m = A("m")
k = A("k")
c = B("c")

g.s = n
j.v = c
j.z = k
n.w = k
n.t = d
n.r = d
d.w = m
d.t = n
d.r = n
m.s = d
k.s = d
c.v = j
c.z = g
assert k.s.t.w.s.w.s.w.txt == "m"