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

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

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

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

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

d.u = h
d.v = l
d.r = c
l.q = h
l.r = e
e.r = l
e.y = k
e.u = h
h.s = d
h.o = c
c.u = j
c.v = l
c.r = i
i.u = h
i.v = l
i.r = d
j.s = c
j.o = i
k.s = i
k.o = c
assert c.r.r.v.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.v: B = None
        self.r: A = None
        self.txt = txt

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

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

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

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

d.u = h
d.v = l
d.r = c
l.q = h
l.r = e
e.r = l
e.y = k
e.u = h
h.s = d
h.o = c
c.u = j
c.v = l
c.r = i
i.u = h
i.v = l
i.r = d
j.s = c
j.o = i
k.s = i
k.o = c
assert c.r.r.v.q.s.txt == "d"