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

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

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

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

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

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

k.r = l
k.s = f
b.u = h
b.v = f
c.u = h
c.v = k
h.u = g
h.v = f
g.u = l
g.v = f
f.r = l
f.s = k
l.u = h
l.v = k
assert g.u.u.u.v.txt == "f"