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

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

d = A("d")
f = B("f")
m = B("m")
e = A("e")
h = A("h")
b = A("b")
c = B("c")
n = A("n")
a = B("a")

d.r = c
d.u = b
f.t = b
f.s = a
m.t = d
m.s = f
e.r = f
e.u = d
h.r = c
h.u = d
b.r = a
b.u = n
c.t = d
c.s = f
n.r = f
n.u = b
a.t = n
a.s = c
assert d.u.r.s.t.u.u.u.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: A = None
        self.txt = txt

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

d = A("d")
f = B("f")
m = B("m")
e = A("e")
h = A("h")
b = A("b")
c = B("c")
n = A("n")
a = B("a")

d.r = c
d.u = b
f.t = b
f.s = a
m.t = d
m.s = f
e.r = f
e.u = d
h.r = c
h.u = d
b.r = a
b.u = n
c.t = d
c.s = f
n.r = f
n.u = b
a.t = n
a.s = c
assert d.u.r.s.t.u.u.u.r.t.txt == "n"