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

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

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

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

f = A("f")
c = B("c")
g = C("g")
n = D("n")
b = D("b")
m = C("m")

f.v = c
f.o = c
f.z = c
c.q = n
c.t = b
g.q = m
g.r = b
n.q = b
b.q = n
m.q = g
m.r = b
assert f.o.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: B = None
        self.z: B = None
        self.txt = txt

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

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

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

f = A("f")
c = B("c")
g = C("g")
n = D("n")
b = D("b")
m = C("m")

f.v = c
f.o = c
f.z = c
c.q = n
c.t = b
g.q = m
g.r = b
n.q = b
b.q = n
m.q = g
m.r = b
assert f.o.q.q.txt == "b"