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

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

g = A("g")
i = B("i")
b = B("b")
h = A("h")
n = A("n")
c = B("c")
f = A("f")
l = B("l")

g.z = c
g.t = l
i.o = c
i.z = f
b.o = c
b.z = g
h.z = l
h.t = c
n.z = b
n.t = l
c.o = i
c.z = n
f.z = l
f.t = l
l.o = c
l.z = f
assert b.z.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: B = None
        self.txt = txt

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

g = A("g")
i = B("i")
b = B("b")
h = A("h")
n = A("n")
c = B("c")
f = A("f")
l = B("l")

g.z = c
g.t = l
i.o = c
i.z = f
b.o = c
b.z = g
h.z = l
h.t = c
n.z = b
n.t = l
c.o = i
c.z = n
f.z = l
f.t = l
l.o = c
l.z = f
assert b.z.z.o.txt == "i"