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

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

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

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

b = A("b")
g = B("g")
j = C("j")
k = D("k")
e = B("e")
c = A("c")
a = D("a")

b.s = g
b.w = a
b.u = k
g.u = j
j.y = b
j.q = b
j.t = g
j.x = c
k.r = c
k.t = j
e.u = j
c.s = e
c.w = k
c.u = a
a.r = b
a.t = j
assert e.u.q.w.t.q.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: D = None
        self.u: D = None
        self.txt = txt

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

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

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

b = A("b")
g = B("g")
j = C("j")
k = D("k")
e = B("e")
c = A("c")
a = D("a")

b.s = g
b.w = a
b.u = k
g.u = j
j.y = b
j.q = b
j.t = g
j.x = c
k.r = c
k.t = j
e.u = j
c.s = e
c.w = k
c.u = a
a.r = b
a.t = j
assert e.u.q.w.t.q.u.r.txt == "c"