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

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

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

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

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

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

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

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

k.y = m
m.y = k
m.x = h
m.z = l
g.z = k
g.w = l
g.v = d
d.z = i
d.w = l
d.v = g
c.y = m
l.y = c
l.x = i
l.z = m
i.y = l
h.y = l
assert m.x.y.y.y.txt == "m"