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

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

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

c = A("c")
f = B("f")
l = C("l")
h = C("h")
i = B("i")

c.s = f
c.x = h
f.q = i
l.t = h
l.r = i
h.t = l
h.r = f
i.q = f
assert i.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: C = None
        self.txt = txt

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

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

c = A("c")
f = B("f")
l = C("l")
h = C("h")
i = B("i")

c.s = f
c.x = h
f.q = i
l.t = h
l.r = i
h.t = l
h.r = f
i.q = f
assert i.q.q.q.q.q.txt == "f"