class A:
    def __init__(self, txt: str):
        self.t: 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: C = None
        self.s: B = None
        self.t: A = None
        self.txt = txt

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

a.t = h
j.p = f
b.u = f
b.s = i
b.t = a
g.t = f
h.u = b
h.s = i
h.t = a
i.p = f
f.u = h
f.s = i
f.t = g
assert h.s.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: 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: C = None
        self.s: B = None
        self.t: A = None
        self.txt = txt

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

a.t = h
j.p = f
b.u = f
b.s = i
b.t = a
g.t = f
h.u = b
h.s = i
h.t = a
i.p = f
f.u = h
f.s = i
f.t = g
assert h.s.p.s.txt == "i"