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

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

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

n.t = h
m.x = c
m.s = n
i.x = j
i.s = j
j.t = h
l.t = a
h.t = j
a.t = c
k.x = l
k.s = j
c.t = h
f.x = a
f.s = a
assert i.x.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

n.t = h
m.x = c
m.s = n
i.x = j
i.s = j
j.t = h
l.t = a
h.t = j
a.t = c
k.x = l
k.s = j
c.t = h
f.x = a
f.s = a
assert i.x.t.t.t.txt == "h"