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

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

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

k = A("k")
d = B("d")
c = C("c")
e = B("e")
j = A("j")
m = A("m")
h = C("h")
b = C("b")
i = A("i")

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

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

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

k = A("k")
d = B("d")
c = C("c")
e = B("e")
j = A("j")
m = A("m")
h = C("h")
b = C("b")
i = A("i")

k.v = c
k.z = i
d.v = h
d.z = c
c.y = m
e.v = b
e.z = h
j.v = c
j.z = k
m.v = h
m.z = k
h.y = j
b.y = m
i.v = h
i.z = k
assert e.z.y.v.y.z.txt == "k"