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

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

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

g = A("g")
k = B("k")
a = C("a")
n = A("n")
f = B("f")
m = B("m")

g.r = f
g.y = n
k.y = g
k.x = a
a.w = m
a.o = g
a.v = g
n.r = f
n.y = g
f.y = n
f.x = a
m.y = g
m.x = a
assert f.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.y: A = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
a = C("a")
n = A("n")
f = B("f")
m = B("m")

g.r = f
g.y = n
k.y = g
k.x = a
a.w = m
a.o = g
a.v = g
n.r = f
n.y = g
f.y = n
f.x = a
m.y = g
m.x = a
assert f.y.y.y.txt == "n"