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

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

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

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

e.t = h
e.s = k
g.y = h
a.p = h
h.t = e
h.s = k
k.y = e
assert g.y.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.s: B = None
        self.txt = txt

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

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

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

e.t = h
e.s = k
g.y = h
a.p = h
h.t = e
h.s = k
k.y = e
assert g.y.s.y.txt == "e"