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

class B:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

a = A("a")
b = B("b")
j = C("j")
l = D("l")
n = C("n")
i = A("i")
f = A("f")

a.x = i
a.v = b
a.y = b
b.w = l
j.u = n
j.q = n
j.o = a
j.v = a
l.v = b
l.o = b
n.u = j
n.q = j
n.o = i
n.v = i
i.x = a
i.v = b
i.y = b
f.x = a
f.v = b
f.y = b
assert l.v.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.v: B = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

a = A("a")
b = B("b")
j = C("j")
l = D("l")
n = C("n")
i = A("i")
f = A("f")

a.x = i
a.v = b
a.y = b
b.w = l
j.u = n
j.q = n
j.o = a
j.v = a
l.v = b
l.o = b
n.u = j
n.q = j
n.o = i
n.v = i
i.x = a
i.v = b
i.y = b
f.x = a
f.v = b
f.y = b
assert l.v.w.v.txt == "b"