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

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

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

d = A("d")
a = B("a")
i = C("i")
n = A("n")
g = C("g")
j = B("j")
h = C("h")

d.z = a
d.x = j
a.y = g
a.x = d
a.o = h
i.z = n
i.p = a
i.v = h
n.z = j
n.x = j
g.z = n
g.p = j
g.v = i
j.y = h
j.x = d
j.o = g
h.z = d
h.p = a
h.v = i
assert d.z.y.v.p.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: B = None
        self.txt = txt

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

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

d = A("d")
a = B("a")
i = C("i")
n = A("n")
g = C("g")
j = B("j")
h = C("h")

d.z = a
d.x = j
a.y = g
a.x = d
a.o = h
i.z = n
i.p = a
i.v = h
n.z = j
n.x = j
g.z = n
g.p = j
g.v = i
j.y = h
j.x = d
j.o = g
h.z = d
h.p = a
h.v = i
assert d.z.y.v.p.y.p.txt == "j"