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

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: B = None
        self.t: B = None
        self.y: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: A = None
        self.q: D = None
        self.v: A = None
        self.txt = txt

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

d = A("d")
b = B("b")
f = C("f")
j = D("j")
k = C("k")
i = A("i")
m = B("m")
h = D("h")
g = D("g")

d.v = f
b.s = m
b.x = m
b.t = m
b.y = m
f.y = i
f.v = i
f.u = d
f.q = j
j.r = k
j.v = k
j.w = b
k.y = i
k.u = i
k.q = h
k.v = d
i.v = k
m.s = b
m.x = b
m.t = b
m.y = b
h.r = k
h.v = k
h.w = b
g.r = f
g.w = b
g.v = k
assert j.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: B = None
        self.t: B = None
        self.y: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: A = None
        self.q: D = None
        self.v: A = None
        self.txt = txt

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

d = A("d")
b = B("b")
f = C("f")
j = D("j")
k = C("k")
i = A("i")
m = B("m")
h = D("h")
g = D("g")

d.v = f
b.s = m
b.x = m
b.t = m
b.y = m
f.y = i
f.v = i
f.u = d
f.q = j
j.r = k
j.v = k
j.w = b
k.y = i
k.u = i
k.q = h
k.v = d
i.v = k
m.s = b
m.x = b
m.t = b
m.y = b
h.r = k
h.v = k
h.w = b
g.r = f
g.w = b
g.v = k
assert j.v.v.v.txt == "f"