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

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

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

e = A("e")
a = B("a")
n = C("n")
h = B("h")
c = A("c")
f = C("f")
j = C("j")

e.o = c
e.v = a
a.z = h
a.s = h
a.x = f
n.y = a
n.w = e
h.z = a
h.s = a
h.x = j
c.o = e
c.v = h
f.y = h
f.w = e
j.y = a
j.w = c
assert e.o.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.v: B = None
        self.txt = txt

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

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

e = A("e")
a = B("a")
n = C("n")
h = B("h")
c = A("c")
f = C("f")
j = C("j")

e.o = c
e.v = a
a.z = h
a.s = h
a.x = f
n.y = a
n.w = e
h.z = a
h.s = a
h.x = j
c.o = e
c.v = h
f.y = h
f.w = e
j.y = a
j.w = c
assert e.o.v.x.txt == "j"