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

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

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

f = A("f")
c = B("c")
i = C("i")
h = B("h")
k = A("k")
m = B("m")

f.w = k
c.y = m
i.q = k
h.y = c
k.w = f
m.y = h
assert c.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

f = A("f")
c = B("c")
i = C("i")
h = B("h")
k = A("k")
m = B("m")

f.w = k
c.y = m
i.q = k
h.y = c
k.w = f
m.y = h
assert c.y.y.y.y.txt == "m"