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

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

e = A("e")
k = B("k")
j = A("j")
n = A("n")
m = A("m")
f = B("f")

e.x = f
k.v = n
k.w = n
j.x = k
n.x = k
m.x = f
f.v = m
f.w = j
assert j.x.v.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

e = A("e")
k = B("k")
j = A("j")
n = A("n")
m = A("m")
f = B("f")

e.x = f
k.v = n
k.w = n
j.x = k
n.x = k
m.x = f
f.v = m
f.w = j
assert j.x.v.x.v.txt == "n"