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

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

d = A("d")
n = B("n")
c = B("c")
b = A("b")
j = A("j")
m = B("m")
l = A("l")

d.x = j
n.v = l
c.v = d
b.x = l
j.x = b
m.v = j
l.x = b
assert c.v.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

d = A("d")
n = B("n")
c = B("c")
b = A("b")
j = A("j")
m = B("m")
l = A("l")

d.x = j
n.v = l
c.v = d
b.x = l
j.x = b
m.v = j
l.x = b
assert c.v.x.x.x.x.x.x.txt == "b"