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

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

g = A("g")
l = B("l")
c = A("c")
m = B("m")
i = A("i")
n = A("n")

g.t = i
g.y = i
l.p = n
c.t = g
c.y = i
m.p = g
i.t = n
i.y = g
n.t = i
n.y = c
assert g.y.y.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.y: A = None
        self.txt = txt

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

g = A("g")
l = B("l")
c = A("c")
m = B("m")
i = A("i")
n = A("n")

g.t = i
g.y = i
l.p = n
c.t = g
c.y = i
m.p = g
i.t = n
i.y = g
n.t = i
n.y = c
assert g.y.y.t.y.txt == "g"