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

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

m = A("m")
g = B("g")
j = A("j")
c = B("c")
e = A("e")
l = B("l")
k = B("k")
i = A("i")

m.p = i
g.y = k
g.w = c
j.p = i
c.y = k
c.w = g
e.p = j
l.y = g
l.w = g
k.y = g
k.w = l
i.p = m
assert c.y.w.y.w.y.y.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

m = A("m")
g = B("g")
j = A("j")
c = B("c")
e = A("e")
l = B("l")
k = B("k")
i = A("i")

m.p = i
g.y = k
g.w = c
j.p = i
c.y = k
c.w = g
e.p = j
l.y = g
l.w = g
k.y = g
k.w = l
i.p = m
assert c.y.w.y.w.y.y.w.w.txt == "g"