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

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

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

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

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

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

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

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

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

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

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