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

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

g = A("g")
c = B("c")
l = B("l")
k = A("k")
h = B("h")

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

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

g = A("g")
c = B("c")
l = B("l")
k = A("k")
h = B("h")

g.y = k
g.z = h
c.o = h
c.v = k
l.o = h
l.v = g
k.y = g
k.z = l
h.o = l
h.v = k
assert l.v.z.v.z.o.txt == "h"