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

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

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

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

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

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

h.o = l
f.w = e
f.q = h
e.w = f
e.q = h
j.w = e
j.q = n
l.w = e
l.q = h
n.o = f
d.w = e
d.q = h
assert j.q.o.q.txt == "h"