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

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

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

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

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

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

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