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

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

d = A("d")
n = B("n")
k = B("k")
j = A("j")

d.v = k
d.s = j
n.u = j
k.u = j
j.v = n
j.s = d
assert j.v.u.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.s: A = None
        self.txt = txt

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

d = A("d")
n = B("n")
k = B("k")
j = A("j")

d.v = k
d.s = j
n.u = j
k.u = j
j.v = n
j.s = d
assert j.v.u.s.s.txt == "j"