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

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

c = A("c")
k = B("k")
d = A("d")
g = B("g")
l = B("l")
j = A("j")
a = A("a")

c.v = j
k.z = d
k.x = g
d.v = j
g.z = j
g.x = k
l.z = d
l.x = k
j.v = c
a.v = j
assert d.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

c = A("c")
k = B("k")
d = A("d")
g = B("g")
l = B("l")
j = A("j")
a = A("a")

c.v = j
k.z = d
k.x = g
d.v = j
g.z = j
g.x = k
l.z = d
l.x = k
j.v = c
a.v = j
assert d.v.v.v.txt == "j"