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

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

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

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

j = A("j")
k = B("k")
a = C("a")
h = D("h")
n = B("n")
g = D("g")
b = C("b")
c = D("c")

j.v = a
j.q = h
k.q = n
k.v = n
k.r = a
a.o = b
a.q = b
a.s = n
h.t = n
h.y = j
n.q = k
n.v = k
n.r = a
g.t = k
g.y = j
b.o = a
b.q = a
b.s = k
c.t = n
c.y = j
assert h.y.q.y.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.q: D = None
        self.txt = txt

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

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

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

j = A("j")
k = B("k")
a = C("a")
h = D("h")
n = B("n")
g = D("g")
b = C("b")
c = D("c")

j.v = a
j.q = h
k.q = n
k.v = n
k.r = a
a.o = b
a.q = b
a.s = n
h.t = n
h.y = j
n.q = k
n.v = k
n.r = a
g.t = k
g.y = j
b.o = a
b.q = a
b.s = k
c.t = n
c.y = j
assert h.y.q.y.v.s.v.txt == "k"