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

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

d = A("d")
f = B("f")
k = A("k")
l = A("l")
e = B("e")
a = A("a")
h = A("h")
j = B("j")
n = B("n")

d.z = n
f.y = j
f.o = k
k.z = n
l.z = e
e.y = j
e.o = d
a.z = j
h.z = n
j.y = f
j.o = k
n.y = f
n.o = a
assert e.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

d = A("d")
f = B("f")
k = A("k")
l = A("l")
e = B("e")
a = A("a")
h = A("h")
j = B("j")
n = B("n")

d.z = n
f.y = j
f.o = k
k.z = n
l.z = e
e.y = j
e.o = d
a.z = j
h.z = n
j.y = f
j.o = k
n.y = f
n.o = a
assert e.y.y.y.txt == "j"