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

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

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

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

l = A("l")
c = B("c")
b = C("b")
h = D("h")
a = C("a")
k = D("k")
e = B("e")
j = A("j")

l.u = j
l.v = b
c.y = j
c.q = j
c.u = e
c.o = a
b.q = j
b.u = a
b.w = a
h.r = k
h.q = k
h.v = e
h.o = e
a.q = j
a.u = b
a.w = b
k.r = h
k.q = h
k.v = c
k.o = c
e.y = j
e.q = j
e.u = c
e.o = b
j.u = l
j.v = a
assert a.q.v.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: C = None
        self.txt = txt

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

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

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

l = A("l")
c = B("c")
b = C("b")
h = D("h")
a = C("a")
k = D("k")
e = B("e")
j = A("j")

l.u = j
l.v = b
c.y = j
c.q = j
c.u = e
c.o = a
b.q = j
b.u = a
b.w = a
h.r = k
h.q = k
h.v = e
h.o = e
a.q = j
a.u = b
a.w = b
k.r = h
k.q = h
k.v = c
k.o = c
e.y = j
e.q = j
e.u = c
e.o = b
j.u = l
j.v = a
assert a.q.v.u.q.txt == "j"