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

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

i = A("i")
g = B("g")
j = A("j")
c = B("c")
l = A("l")
h = B("h")

i.y = j
i.o = l
g.z = i
g.y = c
j.y = l
j.o = i
c.z = l
c.y = h
l.y = j
l.o = j
h.z = i
h.y = g
assert c.y.z.o.y.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: A = None
        self.txt = txt

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

i = A("i")
g = B("g")
j = A("j")
c = B("c")
l = A("l")
h = B("h")

i.y = j
i.o = l
g.z = i
g.y = c
j.y = l
j.o = i
c.z = l
c.y = h
l.y = j
l.o = j
h.z = i
h.y = g
assert c.y.z.o.y.o.o.txt == "l"