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

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

c = A("c")
l = B("l")
h = A("h")
k = B("k")
f = A("f")
n = A("n")
g = A("g")

c.r = n
c.u = l
l.w = k
l.r = c
h.r = n
h.u = k
k.w = l
k.r = f
f.r = g
f.u = k
n.r = f
n.u = k
g.r = f
g.u = l
assert h.r.r.r.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: B = None
        self.txt = txt

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

c = A("c")
l = B("l")
h = A("h")
k = B("k")
f = A("f")
n = A("n")
g = A("g")

c.r = n
c.u = l
l.w = k
l.r = c
h.r = n
h.u = k
k.w = l
k.r = f
f.r = g
f.u = k
n.r = f
n.u = k
g.r = f
g.u = l
assert h.r.r.r.u.r.u.txt == "l"