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

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

i = A("i")
f = B("f")
j = B("j")
n = B("n")
d = A("d")
b = B("b")
g = A("g")
k = B("k")
l = B("l")

i.x = g
i.u = n
f.v = d
j.v = g
n.v = d
d.x = i
d.u = b
b.v = g
g.x = i
g.u = l
k.v = g
l.v = i
assert f.v.u.v.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.u: B = None
        self.txt = txt

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

i = A("i")
f = B("f")
j = B("j")
n = B("n")
d = A("d")
b = B("b")
g = A("g")
k = B("k")
l = B("l")

i.x = g
i.u = n
f.v = d
j.v = g
n.v = d
d.x = i
d.u = b
b.v = g
g.x = i
g.u = l
k.v = g
l.v = i
assert f.v.u.v.u.v.txt == "i"