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

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

i = A("i")
a = B("a")
f = B("f")
n = B("n")
j = B("j")
h = A("h")
c = A("c")
m = A("m")

i.u = h
i.o = j
a.x = h
f.x = m
n.x = i
j.x = m
h.u = m
h.o = f
c.u = h
c.o = n
m.u = i
m.o = a
assert c.u.o.x.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: B = None
        self.txt = txt

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

i = A("i")
a = B("a")
f = B("f")
n = B("n")
j = B("j")
h = A("h")
c = A("c")
m = A("m")

i.u = h
i.o = j
a.x = h
f.x = m
n.x = i
j.x = m
h.u = m
h.o = f
c.u = h
c.o = n
m.u = i
m.o = a
assert c.u.o.x.u.o.txt == "j"