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

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

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

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

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

f.x = k
f.v = b
a.q = g
k.r = a
k.o = a
k.p = a
n.r = k
n.v = k
i.q = b
j.x = k
j.v = n
b.r = k
b.v = k
g.r = k
g.v = k
c.x = k
c.v = b
assert b.r.r.q.r.o.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: D = None
        self.txt = txt

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

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

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

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

f.x = k
f.v = b
a.q = g
k.r = a
k.o = a
k.p = a
n.r = k
n.v = k
i.q = b
j.x = k
j.v = n
b.r = k
b.v = k
g.r = k
g.v = k
c.x = k
c.v = b
assert b.r.r.q.r.o.q.v.txt == "k"