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

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

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

i = A("i")
b = B("b")
a = C("a")
k = C("k")
j = C("j")
n = B("n")
e = B("e")
m = B("m")
g = A("g")
d = C("d")

i.v = b
i.z = g
b.x = g
b.z = i
a.v = g
k.v = i
j.v = g
n.x = i
n.z = g
e.x = g
e.z = g
m.x = g
m.z = g
g.v = n
g.z = i
d.v = i
assert m.x.z.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: A = None
        self.txt = txt

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

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

i = A("i")
b = B("b")
a = C("a")
k = C("k")
j = C("j")
n = B("n")
e = B("e")
m = B("m")
g = A("g")
d = C("d")

i.v = b
i.z = g
b.x = g
b.z = i
a.v = g
k.v = i
j.v = g
n.x = i
n.z = g
e.x = g
e.z = g
m.x = g
m.z = g
g.v = n
g.z = i
d.v = i
assert m.x.z.v.x.txt == "g"