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

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

c = A("c")
a = B("a")
h = B("h")
g = A("g")

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

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

c = A("c")
a = B("a")
h = B("h")
g = A("g")

c.s = g
c.v = g
a.v = c
a.t = c
h.v = c
h.t = c
g.s = c
g.v = c
assert g.s.v.s.txt == "c"