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.txt = txt

d = A("d")
c = B("c")
j = A("j")
h = B("h")
g = A("g")
n = A("n")

d.v = n
c.z = d
j.v = g
h.z = n
g.v = n
n.v = j
assert j.v.v.v.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.txt = txt

d = A("d")
c = B("c")
j = A("j")
h = B("h")
g = A("g")
n = A("n")

d.v = n
c.z = d
j.v = g
h.z = n
g.v = n
n.v = j
assert j.v.v.v.v.v.v.txt == "j"