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

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

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

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

h.s = i
l.p = i
i.u = h
f.p = i
assert f.p.u.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

h.s = i
l.p = i
i.u = h
f.p = i
assert f.p.u.s.u.txt == "h"