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

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

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

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

k = A("k")
i = B("i")
e = C("e")
c = D("c")
g = B("g")
n = D("n")
f = C("f")

k.r = f
i.t = k
i.u = n
i.q = e
e.w = g
e.u = k
c.r = n
g.t = k
g.u = n
g.q = e
n.r = c
f.w = g
f.u = k
assert e.u.r.w.u.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

k = A("k")
i = B("i")
e = C("e")
c = D("c")
g = B("g")
n = D("n")
f = C("f")

k.r = f
i.t = k
i.u = n
i.q = e
e.w = g
e.u = k
c.r = n
g.t = k
g.u = n
g.q = e
n.r = c
f.w = g
f.u = k
assert e.u.r.w.u.r.r.txt == "n"