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

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

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

h = A("h")
e = B("e")
j = C("j")
b = B("b")
i = A("i")
f = B("f")
g = B("g")

h.o = e
h.z = j
e.x = j
e.s = j
e.t = i
j.w = f
b.x = j
b.s = j
b.t = h
i.o = f
i.z = j
f.x = j
f.s = j
f.t = i
g.x = j
g.s = j
g.t = h
assert g.t.z.w.t.z.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: C = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
j = C("j")
b = B("b")
i = A("i")
f = B("f")
g = B("g")

h.o = e
h.z = j
e.x = j
e.s = j
e.t = i
j.w = f
b.x = j
b.s = j
b.t = h
i.o = f
i.z = j
f.x = j
f.s = j
f.t = i
g.x = j
g.s = j
g.t = h
assert g.t.z.w.t.z.w.t.txt == "i"