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

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

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

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

i.y = m
a.r = f
a.w = e
e.q = b
e.v = a
f.r = a
f.w = e
b.q = e
b.v = f
m.y = i
g.y = m
assert m.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

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

i.y = m
a.r = f
a.w = e
e.q = b
e.v = a
f.r = a
f.w = e
b.q = e
b.v = f
m.y = i
g.y = m
assert m.y.y.y.y.y.y.y.txt == "i"