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

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

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

c.t = e
c.p = g
a.z = i
a.w = e
g.t = a
g.p = c
i.z = a
i.w = a
e.z = a
e.w = i
assert c.t.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: A = None
        self.txt = txt

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

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

c.t = e
c.p = g
a.z = i
a.w = e
g.t = a
g.p = c
i.z = a
i.w = a
e.z = a
e.w = i
assert c.t.w.z.txt == "a"