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: A = None
        self.y: D = None
        self.txt = txt

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

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

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

b.v = n
b.q = k
c.q = b
c.y = k
n.z = i
n.q = k
k.p = i
k.t = b
k.r = b
f.z = c
f.q = k
i.q = b
i.y = k
assert i.y.p.q.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: A = None
        self.y: D = None
        self.txt = txt

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

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

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

b.v = n
b.q = k
c.q = b
c.y = k
n.z = i
n.q = k
k.p = i
k.t = b
k.r = b
f.z = c
f.q = k
i.q = b
i.y = k
assert i.y.p.q.v.txt == "n"