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

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

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

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

f = A("f")
e = B("e")
c = C("c")
b = D("b")
i = D("i")
g = C("g")
d = C("d")
j = D("j")
k = D("k")

f.u = b
f.y = b
f.s = g
f.x = d
e.y = j
c.v = g
b.z = d
b.q = f
b.s = c
i.z = g
i.q = f
i.s = c
g.v = c
d.v = c
j.z = c
j.q = f
j.s = d
k.z = g
k.q = f
k.s = c
assert k.q.s.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.s: C = None
        self.y: D = None
        self.x: C = None
        self.txt = txt

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

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

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

f = A("f")
e = B("e")
c = C("c")
b = D("b")
i = D("i")
g = C("g")
d = C("d")
j = D("j")
k = D("k")

f.u = b
f.y = b
f.s = g
f.x = d
e.y = j
c.v = g
b.z = d
b.q = f
b.s = c
i.z = g
i.q = f
i.s = c
g.v = c
d.v = c
j.z = c
j.q = f
j.s = d
k.z = g
k.q = f
k.s = c
assert k.q.s.v.v.v.v.v.txt == "c"