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

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

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

g = A("g")
h = B("h")
e = C("e")
k = C("k")

g.t = k
h.o = g
e.r = g
e.s = g
k.r = g
k.s = g
assert e.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

g = A("g")
h = B("h")
e = C("e")
k = C("k")

g.t = k
h.o = g
e.r = g
e.s = g
k.r = g
k.s = g
assert e.r.t.r.txt == "g"