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

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

i = A("i")
k = B("k")
j = B("j")
f = A("f")
n = A("n")
h = B("h")
d = A("d")

i.o = f
i.t = j
k.x = n
j.x = f
f.o = i
f.t = h
n.o = d
n.t = j
h.x = i
d.o = f
d.t = h
assert j.x.o.t.x.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: B = None
        self.txt = txt

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

i = A("i")
k = B("k")
j = B("j")
f = A("f")
n = A("n")
h = B("h")
d = A("d")

i.o = f
i.t = j
k.x = n
j.x = f
f.o = i
f.t = h
n.o = d
n.t = j
h.x = i
d.o = f
d.t = h
assert j.x.o.t.x.o.o.o.txt == "i"