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

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

g = A("g")
j = B("j")
f = A("f")
i = B("i")
d = A("d")
k = B("k")

g.o = k
g.z = i
j.y = k
j.z = d
f.o = k
f.z = j
i.y = k
i.z = f
d.o = i
d.z = i
k.y = j
k.z = d
assert g.z.z.o.y.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: B = None
        self.txt = txt

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

g = A("g")
j = B("j")
f = A("f")
i = B("i")
d = A("d")
k = B("k")

g.o = k
g.z = i
j.y = k
j.z = d
f.o = k
f.z = j
i.y = k
i.z = f
d.o = i
d.z = i
k.y = j
k.z = d
assert g.z.z.o.y.z.z.txt == "i"