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

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

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

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

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

d.s = j
d.w = k
d.u = f
j.y = e
j.r = k
j.v = f
m.q = g
m.o = f
f.x = k
f.o = d
e.x = d
e.o = d
b.y = f
b.v = f
b.r = k
g.q = m
g.o = e
k.s = b
k.w = d
k.u = f
assert k.u.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: A = None
        self.u: D = None
        self.txt = txt

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

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

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

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

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