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

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

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

b = A("b")
j = B("j")
h = C("h")
c = C("c")
l = A("l")
g = B("g")

b.s = c
j.t = c
h.s = j
c.s = g
l.s = c
g.t = h
assert c.s.t.s.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

b = A("b")
j = B("j")
h = C("h")
c = C("c")
l = A("l")
g = B("g")

b.s = c
j.t = c
h.s = j
c.s = g
l.s = c
g.t = h
assert c.s.t.s.t.s.txt == "g"