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

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

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

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

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

l.r = g
n.y = l
b.s = e
k.o = n
k.u = l
k.q = i
k.r = e
i.y = l
g.s = l
e.r = g
f.o = i
f.q = i
f.u = e
f.r = l
assert k.q.y.r.s.r.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

l.r = g
n.y = l
b.s = e
k.o = n
k.u = l
k.q = i
k.r = e
i.y = l
g.s = l
e.r = g
f.o = i
f.q = i
f.u = e
f.r = l
assert k.q.y.r.s.r.s.r.txt == "g"