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

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

g = A("g")
b = B("b")
k = A("k")
d = A("d")
m = A("m")
n = A("n")
l = B("l")

g.u = l
b.r = g
b.s = m
k.u = l
d.u = l
m.u = l
n.u = b
l.r = d
l.s = k
assert g.u.s.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

g = A("g")
b = B("b")
k = A("k")
d = A("d")
m = A("m")
n = A("n")
l = B("l")

g.u = l
b.r = g
b.s = m
k.u = l
d.u = l
m.u = l
n.u = b
l.r = d
l.s = k
assert g.u.s.u.r.u.txt == "l"