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

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

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

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

l = A("l")
n = B("n")
g = C("g")
e = D("e")
c = B("c")
j = D("j")
d = A("d")
k = B("k")
i = C("i")

l.r = d
n.s = j
n.q = d
n.z = d
n.x = c
g.q = i
e.t = c
e.u = i
c.s = e
c.q = d
c.z = d
c.x = n
j.t = c
j.u = g
d.r = l
k.s = e
k.q = d
k.z = d
k.x = c
i.q = g
assert l.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

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

l = A("l")
n = B("n")
g = C("g")
e = D("e")
c = B("c")
j = D("j")
d = A("d")
k = B("k")
i = C("i")

l.r = d
n.s = j
n.q = d
n.z = d
n.x = c
g.q = i
e.t = c
e.u = i
c.s = e
c.q = d
c.z = d
c.x = n
j.t = c
j.u = g
d.r = l
k.s = e
k.q = d
k.z = d
k.x = c
i.q = g
assert l.r.r.r.txt == "d"