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

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

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

j = A("j")
l = B("l")
g = C("g")
e = A("e")
c = C("c")
k = B("k")

j.o = c
j.w = e
l.y = g
l.t = e
l.x = k
g.o = c
e.o = c
e.w = j
c.o = g
k.y = c
k.t = j
k.x = l
assert k.y.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.w: A = None
        self.txt = txt

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

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

j = A("j")
l = B("l")
g = C("g")
e = A("e")
c = C("c")
k = B("k")

j.o = c
j.w = e
l.y = g
l.t = e
l.x = k
g.o = c
e.o = c
e.w = j
c.o = g
k.y = c
k.t = j
k.x = l
assert k.y.o.o.o.o.o.txt == "g"