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

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

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

b = A("b")
g = B("g")
f = C("f")
e = A("e")
a = C("a")

b.o = e
b.z = e
g.v = b
g.s = f
f.y = a
e.o = b
e.z = b
a.y = f
assert a.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.z: A = None
        self.txt = txt

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

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

b = A("b")
g = B("g")
f = C("f")
e = A("e")
a = C("a")

b.o = e
b.z = e
g.v = b
g.s = f
f.y = a
e.o = b
e.z = b
a.y = f
assert a.y.y.y.y.y.txt == "f"