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

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

c = A("c")
k = B("k")
a = A("a")
n = B("n")
d = A("d")
g = B("g")
f = A("f")
e = A("e")

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

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

c = A("c")
k = B("k")
a = A("a")
n = B("n")
d = A("d")
g = B("g")
f = A("f")
e = A("e")

c.u = k
k.w = a
a.u = g
n.w = e
d.u = k
g.w = a
f.u = g
e.u = k
assert d.u.w.u.w.u.txt == "g"