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

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

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

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

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

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

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

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

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

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

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