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

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

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

k = A("k")
b = B("b")
a = C("a")
i = C("i")
g = B("g")

k.o = g
k.y = a
k.z = a
b.u = g
b.x = k
b.s = i
a.p = g
a.r = i
a.o = i
i.p = b
i.r = a
i.o = a
g.u = b
g.x = k
g.s = a
assert i.p.s.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: C = None
        self.z: C = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
a = C("a")
i = C("i")
g = B("g")

k.o = g
k.y = a
k.z = a
b.u = g
b.x = k
b.s = i
a.p = g
a.r = i
a.o = i
i.p = b
i.r = a
i.o = a
g.u = b
g.x = k
g.s = a
assert i.p.s.p.s.txt == "i"