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

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.x: C = None
        self.txt = txt

m = A("m")
f = B("f")
i = C("i")
j = D("j")
e = D("e")
n = B("n")
b = A("b")

m.y = b
f.w = m
f.q = e
f.v = b
i.s = f
j.s = i
j.x = i
e.s = i
e.x = i
n.w = b
n.v = b
n.q = j
b.y = m
assert f.v.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.x: C = None
        self.txt = txt

m = A("m")
f = B("f")
i = C("i")
j = D("j")
e = D("e")
n = B("n")
b = A("b")

m.y = b
f.w = m
f.q = e
f.v = b
i.s = f
j.s = i
j.x = i
e.s = i
e.x = i
n.w = b
n.v = b
n.q = j
b.y = m
assert f.v.y.y.y.y.y.y.txt == "b"