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

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

b = A("b")
c = B("c")
g = B("g")
h = A("h")
j = A("j")
i = B("i")
k = B("k")

b.y = k
b.o = h
c.w = i
c.p = g
g.w = k
g.p = i
h.y = c
h.o = j
j.y = i
j.o = h
i.w = k
i.p = c
k.w = g
k.p = i
assert b.o.o.y.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: A = None
        self.txt = txt

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

b = A("b")
c = B("c")
g = B("g")
h = A("h")
j = A("j")
i = B("i")
k = B("k")

b.y = k
b.o = h
c.w = i
c.p = g
g.w = k
g.p = i
h.y = c
h.o = j
j.y = i
j.o = h
i.w = k
i.p = c
k.w = g
k.p = i
assert b.o.o.y.p.p.txt == "g"