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

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

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

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

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

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

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

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

h.t = c
h.y = i
c.w = k
c.q = h
k.s = h
i.t = c
i.y = h
assert h.y.y.y.txt == "i"