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

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

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

f = A("f")
i = B("i")
b = C("b")
a = A("a")
h = B("h")
c = C("c")

f.y = c
i.t = c
i.w = a
i.x = a
b.y = c
a.y = c
h.t = c
h.w = f
h.x = f
c.y = b
assert a.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

f = A("f")
i = B("i")
b = C("b")
a = A("a")
h = B("h")
c = C("c")

f.y = c
i.t = c
i.w = a
i.x = a
b.y = c
a.y = c
h.t = c
h.w = f
h.x = f
c.y = b
assert a.y.y.y.y.y.txt == "c"