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

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

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

d = A("d")
e = B("e")
j = C("j")
a = B("a")
m = B("m")
k = C("k")
c = B("c")

d.z = k
e.v = m
e.s = d
j.z = d
j.r = d
j.y = k
a.v = m
a.s = d
m.v = e
m.s = d
k.z = d
k.r = d
k.y = j
c.v = e
c.s = d
assert m.s.z.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

d = A("d")
e = B("e")
j = C("j")
a = B("a")
m = B("m")
k = C("k")
c = B("c")

d.z = k
e.v = m
e.s = d
j.z = d
j.r = d
j.y = k
a.v = m
a.s = d
m.v = e
m.s = d
k.z = d
k.r = d
k.y = j
c.v = e
c.s = d
assert m.s.z.y.y.y.y.y.txt == "j"