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

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

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

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

a = A("a")
n = B("n")
k = C("k")
g = D("g")
c = A("c")
e = D("e")
l = D("l")

a.u = k
n.v = c
k.t = a
g.r = e
g.y = n
g.s = n
g.q = c
c.u = k
e.r = l
e.y = n
e.s = n
e.q = a
l.r = e
l.y = n
l.s = n
l.q = a
assert n.v.u.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

a = A("a")
n = B("n")
k = C("k")
g = D("g")
c = A("c")
e = D("e")
l = D("l")

a.u = k
n.v = c
k.t = a
g.r = e
g.y = n
g.s = n
g.q = c
c.u = k
e.r = l
e.y = n
e.s = n
e.q = a
l.r = e
l.y = n
l.s = n
l.q = a
assert n.v.u.t.u.txt == "k"