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

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

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

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

n = A("n")
g = B("g")
k = C("k")
l = D("l")
d = C("d")
j = D("j")
a = D("a")

n.t = g
n.q = g
n.u = l
g.t = n
g.y = k
g.v = k
k.q = j
l.r = a
d.q = j
j.r = a
a.r = l
assert g.t.q.t.u.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.u: D = None
        self.q: B = None
        self.txt = txt

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

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

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

n = A("n")
g = B("g")
k = C("k")
l = D("l")
d = C("d")
j = D("j")
a = D("a")

n.t = g
n.q = g
n.u = l
g.t = n
g.y = k
g.v = k
k.q = j
l.r = a
d.q = j
j.r = a
a.r = l
assert g.t.q.t.u.r.r.txt == "l"