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

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

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

h = A("h")
a = B("a")
g = C("g")
j = A("j")

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

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

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

h = A("h")
a = B("a")
g = C("g")
j = A("j")

h.t = a
h.s = a
a.y = h
a.t = g
g.v = h
j.t = a
j.s = a
assert h.t.y.s.y.txt == "h"