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

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

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

d = A("d")
c = B("c")
g = C("g")
b = B("b")
h = B("h")
a = C("a")
j = A("j")

d.t = h
d.z = h
d.o = j
c.o = b
c.z = g
g.x = c
g.t = h
g.z = j
b.o = h
b.z = g
h.o = c
h.z = a
a.x = c
a.t = b
a.z = j
j.t = b
j.o = d
j.z = h
assert j.t.z.t.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.o: A = None
        self.z: B = None
        self.txt = txt

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

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

d = A("d")
c = B("c")
g = C("g")
b = B("b")
h = B("h")
a = C("a")
j = A("j")

d.t = h
d.z = h
d.o = j
c.o = b
c.z = g
g.x = c
g.t = h
g.z = j
b.o = h
b.z = g
h.o = c
h.z = a
a.x = c
a.t = b
a.z = j
j.t = b
j.o = d
j.z = h
assert j.t.z.t.z.z.txt == "j"