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

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

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

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

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

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

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

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

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

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

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